Yes (using different remote), and that is why Git 2.5 introduces a new ref shorthand @{push}
.
See "Viewing Unpushed Git Commits"
What commands can you use to change remote URL for fetch or push separately?
You need a separate remote:
git remote add myfork /url/for/my/fork
git config remote.pushdefault myfork
The GitHub blog post "Improved support for triangular workflows" illustrates the use of @{push}
:
See what commits you've added to your current branch since the last push:
git clone https://github.com/YOUR-USERNAME/atom
cd atom
git config remote.pushdefault origin
git config push.default current
remote.pushdefault
specifies where to push (to which remote repo).
push.default
specifies what to push (what refspec), when no refspec is explicitly given.
current
, in that latter case, means "push the current branch to update a branch with the same name on the receiving end."
The following branch will fetch from one url, push to another:
git remote add upstream https://github.com/atom/atom
git fetch upstream
git checkout -b whizbang upstream/master
(Here the whizbang
branches tracks upstream/master
, but pushes to origin/whizbang
)
git log @{push}..
This uses the new @{push}
notation, which denotes the current value of the remote-tracking branch that the current branch would be pushed to by git push, namely origin/whizbang
.
You can also refer to the push destination of an arbitrary branch using the notation whizbang@{push}
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…