Please help to clarify the question below.
I have done the following steps.
- git checkout -b test origin/master
- Made some code changes
- git add followed by git commit and git push
- One of my colleagues checked out my test branch. He did not add any new changes in it
- 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.
CodePudding user response:
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>
CodePudding user response:
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.