Reputation: 9828
I have been learning to use git rebase -i
lately to clean up my commits before I push my changes.
However, I find that I am doing git log
, then checking the remote repo via web gui to see which commit was the last one I pushed, then manually working out how my commits that was so I can use
git rebase -i HEAD~[amount]
It seems pretty long winded to have to use a web gui to check which commit was the last one pushed* to the remote repo when everything else can be done in command line
Suggestions for a better work flow?
*since the golden rule of rebasing is not to rebase commits already pushed to the repo
Upvotes: 1
Views: 56
Reputation: 486
If you do git branch -a
, you will see additional branches names, starting with remote/<remote-name>
. Those are pointing to branches on the selected remote. Now, the thing is, those can be used just like any other tag or branch name.
For example, assume branch net
that is set to push to remote origin
branch network
. It's name will have format origin/network
. To see last commit pushed there you may use git show origin/network
. To rebase everything until this commit, try git rebase -i origin/network
.
Upvotes: 2
Reputation: 43304
You can use --decorate
Example $ git log --decorate
This will tell you which tag or branch is on which commit in the log overview.
In your case you want to be looking for origin/master
and/or origin/HEAD
. They are colored red by default.
I always use this command to get a compact and understandable overview of the log history:
$ git log --decorate --branches --graph --pretty="oneline" --abbrev-commit
It has some other nice parameters that help construct a clear overview. You don't have to use it, but you can try it. It might be very helpful, especially when you work with different branches who have a different history.
In simple scenario's it looks like this (commit messages are substituted in this example)
* 9562f31 (HEAD -> master, origin/master, origin/HEAD) Added A
* 57b2de9 Added B
* 687e7d6 Added C
* 187aac7 Added D
* 1fc4a05 Added E
in your case the (origin/master, origin/HEAD
would be a little further down, while master
and HEAD
might be at the top.
Upvotes: 1