Lara Lara - 2 months ago 5
Git Question

merge from another repo git

I cloned a project from git and I did some changes and I now I want to import the changes done on the original repo and keep my changes in the same time !
I added a new remote :

git add remote original_repo

git fetch original_repo

git checkout -b branch_for_merge original_repo/master

the problem is when I do :
git status

I can't find the changed files , it gives me :

nothing to commit, working directory clean

what should I do to find changes and resolve conflicts and merge the branch ?


git checkout -b branch_for_merge original_repo/master

This makes branch_for_merge point to the same commit as original_repo/master and makes no sense at all.

What you want to do is this (assuming you did your work on your local master branch):

git checkout master    # just to be sure
git pull original_repo master

This will fetch any changes from original_repo (no-op since you already did so yourself) and then do a git merge original_repo/master for you. The only benefit over git fetch ; git merge original/repo_master is a slightly more helpfull commit message (which you can edit of course).