How to check the git fetch's content?
I want use git fetch & git rebase
to merge the content of upstream.
after I exec git fetch:
$ git fetch upstream
From github.com:kubernetes/kubernetes
* [new branch] feature-rate-limiting -> upstream/feature-rate-limiting
* [new branch] feature-serverside-apply -> upstream/feature-serverside-apply
* [new branch] feature-workload-ga -> upstream/feature-workload-ga
* [new branch] master -> upstream/master
* [new branch] release-0.10 -> upstream/release-0.10
* [new branch] release-0.12 -> upstream/release-0.12
* [new branch] release-0.13 -> upstream/release-0.13
* [new branch] release-0.14 -> upstream/release-0.14
* [new branch] release-0.15 -> upstream/release-0.15
* [new branch] release-0.16 -> upstream/release-0.16
* [new branch] release-0.17 -> upstream/release-0.17
* [new branch] release-0.18 -> upstream/release-0.18
* [new branch] release-0.19 -> upstream/release-0.19
* [new branch] release-0.20 -> upstream/release-0.20
* [new branch] release-0.21 -> upstream/release-0.21
* [new branch] release-0.4 -> upstream/release-0.4
* [new branch] release-0.5 -> upstream/release-0.5
* [new branch] release-0.6 -> upstream/release-0.6
* [new branch] release-0.7 -> upstream/release-0.7
* [new branch] release-0.8 -> upstream/release-0.8
* [new branch] release-0.9 -> upstream/release-0.9
* [new branch] release-1.0 -> upstream/release-1.0
* [new branch] release-1.1 -> upstream/release-1.1
* [new branch] release-1.10 -> upstream/release-1.10
* [new branch] release-1.11 -> upstream/release-1.11
* [new branch] release-1.12 -> upstream/release-1.12
* [new branch] release-1.13 -> upstream/release-1.13
* [new branch] release-1.14 -> upstream/release-1.14
* [new branch] release-1.15 -> upstream/release-1.15
* [new branch] release-1.16 -> upstream/release-1.16
* [new branch] release-1.17 -> upstream/release-1.17
* [new branch] release-1.18 -> upstream/release-1.18
* [new branch] release-1.19 -> upstream/release-1.19
* [new branch] release-1.2 -> upstream/release-1.2
* [new branch] release-1.20 -> upstream/release-1.20
* [new branch] release-1.21 -> upstream/release-1.21
* [new branch] release-1.22 -> upstream/release-1.22
* [new branch] release-1.3 -> upstream/release-1.3
* [new branch] release-1.4 -> upstream/release-1.4
* [new branch] release-1.5 -> upstream/release-1.5
* [new branch] release-1.6 -> upstream/release-1.6
* [new branch] release-1.6.3 -> upstream/release-1.6.3
* [new branch] release-1.7 -> upstream/release-1.7
* [new branch] release-1.8 -> upstream/release-1.8
* [new branch] release-1.9 -> upstream/release-1.9
I have two questions about this:
- why it display so many branches? and when I show branch of my local/repo, there only display master:
$ git branch
* master
2.how can I display the fetched content from upstream I have not rebased?
CodePudding user response:
- why it display so many branches?
Because that's how many got made on the remote since you last fetched. And it seems they're using branches instead of tags for releases.
They are all stored in your repository as "remote tracking branches". These are just like regular branches, but you don't commit to them. They track a branch on the remote. Each remote tracking branch is prefixed with the name of the remote.
* [new branch] feature-workload-ga -> upstream/feature-workload-ga
This tells you that upstream added a new branch called feature-workload-ga and you are tracking it as upstream/feature-workload-ga.
and when I show branch of my local/repo, there only display master
By default, git branch
only shows your local branches. To see the remote tracking branches, upstream/whatever, use git branch -r
. git branch -a
shows all branches.
See Remote Branches in Pro Git for more.
2.how can I display the fetched content from upstream I have not rebased?
Assuming you want to see a diff of your master vs upstream/master you can do git diff master..upstream/master
.
CodePudding user response:
these branches are stored in your repo as remote branches, you can list them using :
git branch -r
since your active local branch is
master
, you probably want to inspect the remoteupstream/master
branch :git diff master upstream/master git log --oneline --graph master upstream/master
Using git diff
, the 3 dots notation will show you the modifications the second branch since it "forked" from the first one :
# diff on 'upstream/master' since it forked from 'master' :
git diff master...upstream/master
# diff on your local 'master' branch since it forked from 'upstream/master' :
git diff upstream/master...master
The "fork point" is the commit that git would use as a merge base. Quoting the docs :
git diff A...B
is equivalent togit diff $(git merge-base A B) B
.
Using git log
, the 3 dots notation will list the commits on both branches since the merge base. Add --boundary
to also view the merge base in the graph :
git log --oneline --graph --boundary master...upstream/master