akashrajkn
akashrajkn

Reputation: 2315

Merge the changes made in the master while keeping the changes made locally in git

I have cloned a particular repo. Suppose it is at state A. I have made some changes to it locally, suppose it is A -> B. But some changes have already been updated in the master branch of repo, suppose it is A->C. Now, I need to update my local repo and then merge my changes to it. That is, it should be A-> C-> B . How do I do this ? After googling a lot, I found out it can done using

git stash

Some blogs said that even

git rebase 

can be used to do it. Can you please help with the command sequence that I need to follow? (for merging conflicts I am using kDiff3)

Upvotes: 2

Views: 54

Answers (1)

Phil Miller
Phil Miller

Reputation: 38118

If you aren't ready to commit your changes

git stash
git pull
git stash pop

If you are ready to commit your changes, then commit then. Then you can just

git pull --rebase

If you have some committed changes, and some changes you're not ready to commit, you can combine these:

git stash
git pull --rebase
git stash pop

Upvotes: 3

Related Questions