I have the following branches:
* master
newbranch
remotes/origin/HEAD -> origin/master
remotes/origin/api-notes
remotes/origin/event-creation-validation
remotes/origin/master
remotes/origin/organizerlocation-bug-demo
remotes/origin/ticket-180
Is the current branch master different from origin/master or are these branches working together?
How can I detect the last changes in the different branches and how can I delete them to cleanup?
Thank you very much.
You do not have any reason to worry or cleanup anything. This is why:
If you created master as tracking branch or if you cloned it (by default clone creates tracking master), then yes, sort of. Tracking simply means that git will use this branch mapping as a default target for push and for merge. It will also display status messages like "branch master is ahead of origin/master by 2 commits".
I would simply use
git branch -av
This shows short commit id and short summary for all branches, local and remote.
On top of this, you may want to use git log .
git log --decorate
is very helpful to see which branches point to what commits. In most recent git versions (1.7.11+) you can enable it permanently using this command:
git config --global log.decorate short
You don't - remote branches are not yours. Remote branches simply reflect state of remote at a time last git fetch
was performed. You cannot create them, and even if you remove them using git branch -rd
, when next time you do git fetch
these remote branch pointers will be immediately back.
But if you completely remove this remote:
git remote rm origin
then all remote branches for this remote will be gone at once.
1/ Is the current branch master different from origin/master or are these branches working together?
It is different (even if it started from origin/master
after the clone), and is not tracking origin/master
(see "how do I change the remote a git branch is tracking?").
2/ how can I delete them to cleanup
You can delete a branch from the remotes namespace with:
git branch -rd origin/api-notes
(More at "How do you Remove an Invalid Remote Branch Reference from Git?")
You can git diff or git log two branches to see the commits you don't have:
See "Git diff .. ? What's the difference between having ..
and no dots?".
See also "Git: Compare All Local Commits to Remote Repo Version".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With