Merge conflict in Rebasing

Hi Team, Please look at this scenario:

I have remote repo and its main branch has all the latest changes. Now my local master branch doesn’t have all those files and updates. I wan to bring all those updates to my local master branch first and then i would like to do git rebase master from my feature branch.

Now the scenario question is let’s say i am on my feature branch and i have updated one file and added some text and pushed it to remote repo and after pushing the changes i realised that remote master branch is already updated with different text in remote repo. Now as i dont have latest files and other changes so i went back to master branch and did “git pull origin master”, changes have been pulled from remote repo but when i again went back to my feature branch and ran “git rebase master” i got the error message:

sarah (story/hare-and-tortoise)$ git rebase master
Auto-merging story-index.txt
CONFLICT (content): Merge conflict in story-index.txt
error: could not apply 43c4766… added text
Resolve all conflicts manually, mark them as resolved with
“git add/rm <conflicted_files>”, then run “git rebase --continue”.
You can instead skip this commit: run “git rebase --skip”.
To abort and get back to the state before “git rebase”, run “git rebase --abort”.
Could not apply 43c4766… added text

and git created a new branch for me “sarah ((no branch, rebasing story/hare-and-tortoise))” where i could see both changes in my test file “remote repo changes” and “my changes which i pushed from feature branch to remote repo” then i tried to sort this file in this current no branch by running the following command and still i am not able to resolve this:

sarah ((no branch, rebasing story/hare-and-tortoise))$ vi story-index.txt
sarah ((no branch, rebasing story/hare-and-tortoise))$ git add .
sarah ((no branch, rebasing story/hare-and-tortoise))$ git commit -m “added new text”
[detached HEAD 402a345] added new text
1 file changed, 1 insertion(+)
sarah ((no branch, rebasing story/hare-and-tortoise))$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

git push origin HEAD:<name-of-remote-branch>

sarah ((no branch, rebasing story/hare-and-tortoise))$ git checkout story/hare-and-tortoise
Warning: you are leaving 2 commits behind, not connected to
any of your branches:

402a345 added new text
a710666 Add first draft of hare-and-tortoise story

If you want to keep them by creating a new branch, this may be a good time
to do so with:

git branch 402a345

Switched to branch ‘story/hare-and-tortoise’
Your branch is up to date with ‘origin/story/hare-and-tortoise’.
sarah (story/hare-and-tortoise)$ cat story-index.txt
hello
sarah (story/hare-and-tortoise)$ git rebase master
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase. If that is the
case, please try
git rebase (–continue | --abort | --skip)
If that is not the case, please
rm -fr “.git/rebase-merge”
and run me again. I am stopping in case you still have something
valuable there.

Hello, shara,
first, you need to reset your local repo to be the same as the remote repo by using
git reset --hard origin master
then you need to do your change and commit it and push it.