Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Result of the command git merge origin/master:

javanoob@DELL:~/workspace/PROJECT_One$ git merge origin/master 
Updating d83ef9c..dd520ea
error: The following untracked working tree files would be overwritten by merge:
    sample.txt
Please move or remove them before you can merge.
Aborting

Result of the command git merge master:

javanoob@DELL:~/workspace/PROJECT_One$ git merge master
Already up-to-date.

When I do the command git merge origin/master It shows that there are some files which will be overwritten but if I do the same command without the prefix origin/ it says everything is already up-to-date.

What is wrong in this setup?

I don't know if it matters but before running these commands, I did run the command git fetch origin

question from:https://stackoverflow.com/questions/34496806/difference-between-git-merge-master-and-origin-master

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
184 views
Welcome To Ask or Share your Answers For Others

1 Answer

git fetch fetches information on remote branches, but does not make any changes to your local master branch. Because of this, master and origin/master are still diverged. You'd have to merge them by using git pull.

When you make a commit, your local master branch is ahead of origin/master until you push those changes. This case is the opposite, where the origin/master branch is ahead of your local master branch. This is why you are getting different outcomes.

Read https://stackoverflow.com/a/7104747/2961170 for more information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...