Question

I pulled a remote repository's master branch and made a new branch. I modified a few files, committed them, and pushed to the new branch on the remote server. I did this several times over the next day.

Then, I checked out the master branch and did a git pull. I then checked out my new branch, and ran git rebase master. This is where it gets a little hazy, and my apologies upfront if I don't explain very well what happened next, as I'm going on memory.

My rebase had some conflicts in a couple of files. I was told to fix the conflicts, then call git rebase --continue.

I generally diff and merge using a 3rd party tool (Araxis) but in this case the git prompt remained where it was, as though it was waiting for me to edit the conflicts right then and get back to it. So, I opened my text editor and removed the appropriate '<<<<' and '-----' bits we've all seen when dealing with conflicts, and saved the files the way I wanted them to look.

From the waiting prompt I then typed git rebase --continue and was promptly told to add the files first, then call rebase. So I ran git add * and then git rebase --continue and the actions completed. I was then told I should consider pushing, as origin/new branch was a few commits behind. So I ran git push.

Then I figured I should play it safe and make sure everything was ok, so I called git checkout master, called git pull, then checked out the new branch and called git pull followed by git rebase master and the same files were conflicting again, and it felt like I had just completed a circle.

My questions are: what would be a more appropriate series of steps to have taken to keep things smooth when the rebase had conflicts, and does anyone know how the steps that I did take led to the circle I (admittedly, not very well) described above?

Was it helpful?

Solution

and called git pull followed by git rebase master

That is the part where it went wrong.
You don't have to pull your remote branch again, adding a commit representing then changes from origin, which, once rebased (again) on master, would generate the same conflicts.

I usually do a (since I don't work on master, but only on mybranch):

git checkout mybranch

# Let's not modify any local file
git fetch

# reset my local master branch to the one I just fetched
git branch -f master origin/master

git rebase master
# resolve conflicts
# git add, git rebase --continue
git push
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top