user1838836
user1838836

Reputation: 1

git merge without commiting local changes beforehand

Maybe this has been answered before, but I can't seem to find it. Let me illustrate my problem. I checked out a git repository and then done some modifications to the files. This has been some time ago and I now like to merge the latest updates from the repository with my changes. The problem is, that I dont use git as version control, since we use mercurial in our day to day operations. How can I get the latest changes without having to commit to git (which I can't do anyways).

Upvotes: 0

Views: 96

Answers (1)

Alex North-Keys
Alex North-Keys

Reputation: 4363

Stuff your changes in the stash (using git stash), pull from the remote repo with git pull, then use git stash apply (or pop, if you're confident it'll work). No formal commits made.

git stash
git pull        # or: git fetch ; git checkout --force origin/master
git stash pop   # or: git stash apply

If there are conflicting changes between the upstream source and your own code, git can produce slightly more readable diff output in these situations with the following in ~/.gitconfig - YMMV, but it might be worth a try:

[merge]
    conflictstyle = diff3

Upvotes: 1

Related Questions