Chen Li Yong
Chen Li Yong

Reputation: 6107

How to merge my uncommitted files with the changes from the repository, within the same branch?

I have one file, say, index.html.

I change line 1000-1200 on the file. Another coworker, working on the same branch with me, commit changes on line 600-800 before I had the chance to commit and push.

When I tried to push my commit, my github desktop for mac said something like the head on the repo is greater than my head, so I need to do pull first. When I tried to pull, my github deskop told me that the changes on index.html will overwrite my changes.

I just recently use github, for like 1 week. This never happens when I used SVN with TortoiseSVN in the past. It always tried to merge the changes first with my uncommitted files, and then if it can't, it will show me where the conflicted lines are, and which lines I should decided taken from which version. I don't have that option in github desktop. I also don't understand how to do that in git console.

So, how to do that?

Upvotes: 0

Views: 70

Answers (1)

merlin2011
merlin2011

Reputation: 75619

You must stash your local changes, then pull the remote changes and then unstash your local changes onto the updated working tree.

Any conflicts between your changes and the remote changes will show up when you do git stash pop.

git stash
git pull
git stash pop

Upvotes: 2

Related Questions