简体   繁体   中英

Git pull command

Please help to clarify the question below.

I have done the following steps.

  1. git checkout -b test origin/master
  2. Made some code changes
  3. git add followed by git commit and git push
  4. One of my colleagues checked out my test branch. He did not add any new changes in it
  5. Now I updated test branch with new code changes and pushed it.

I would like to know, how would my colleague who has already checked out test branch,be able to see the latest changes that I did in step 5 .

First, when you create a branch, do so with git switch : git switch -c test origin/master , preferably after a git fetch (in order for origin/master to reflect the latest commit pushed there)

Then make sure your first push is git push -u origin test in order to establish a remote tracking branch origin/test , which will facilitate the subsequent pushes to that branch.

When you colleague do a git switch test (after a fetch ), the default guess mode automatically establish a remote tracking branch (as if they typed git switch -c <branch> --track <remote>/<branch> )
That is why a simple git pull would be enough to update their local test branch after your step 5.

The only way to do this is, as suggested by @larsks, to issue a git pull .

Instead, if anybody need to inspect changes before pulling them, he can:

git fetch --all
git diff HEAD..origin/<BRANCH-NAME>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM