문제

I read that, after doing a git fetch, your local repo has all the commits from the original repo, but that they are "not yet integrated into the cloned repository's local branches".

What does this mean/imply?

Do I then need to checkout my branch to pull the changes down into my local working copy? Or does it imply something else? Thanks in advance!

도움이 되었습니까?

해결책 2

Git has two commands to update itself from a remote repository. git fetch will synchronize you with another repo, pulling down any data that you do not have locally and giving you bookmarks to where each branch on that remote was when you synchronized. These are called "remote branches" and are identical to local branches except that Git will not allow you to check them out - however, you can merge from them, diff them to other branches, run history logs on them, etc. You do all of that stuff locally after you synchronize.

The second command that will fetch down new data from a remote server is git pull. This command will basically run a git fetch immediately followed by a git merge of the branch on that remote that is tracked by whatever branch you are currently in. Running the fetch and merge commands separately involves less magic and less problems, but if you like the idea of pull, you can read about it in more detail in the official docs.

Copied from here

다른 팁

git fetch updates the local copies of remote-tracking branches. If the remote you have configured is origin (which is usually the case) then git fetch will update origin/master as well as any other branches that exist remotely. These branches point to the commit that the remote branches are currently on.

For example, consider this invocation of git log --pretty=oneline --abbrev-commit --graph --decorate --all:

* 46960d3 (origin/master) Commit 5
* 8b050c8 Commit 4
* cee210b (HEAD, master) Commit 3
* 075aafe Commit 2
* 69ade0a Commit 1

In this case, git fetch retrieved two new commits (4 and 5), but the local master branch is still behind.

To rectify the situation, one must check out master if it is not already checked out (git checkout master) and then merge with the new commits (git merge origin/master).

git pull is effectively a synonym for "fetch from the remote that the current branch is tracking, then merge with the tip commit that was fetched." In this case it would be equivalent to git fetch origin && git merge origin/master.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top