Open auntieNeo opened 10 years ago
You can create a git alias:
git config --global alias.unpushed '!sh -c "git status --short; git log --branches --not --remotes --simplify-by-decoration --decorate --oneline; git stash list"'
Then call via
gr git unpushed
The
gr status
command currently only looks for changes in the currently checked out branch. It misses un-pushed commits in branches that aren't checked out. This is a problem for repositories where I might be working on multiple branches at a time, make a commit on one branch, and checkout another branch without pushing. The branch might not even be tracking any remote branches. If that branch is stuck on my laptop or something while it's asleep, I could easily misplace a lot of work.The scenario is easy to reproduce:
If I'm to trust the output of
gr status
, that branch is as good as lost.Fortunately, git has built in functionality to search for this type of thing. The command is rather long though:
I found this command with a quick Google search at this thread on Stackoverflow: http://stackoverflow.com/questions/15134438/git-show-unpushed-work
This functionality is rather important to me, so I might start working on a patch if I can find the time. Another thing to add would be checking stashed changes or un-pushed submodule changes. The idea is that
gr status
should pick up on ANY work I haven't uploaded somewhere, so it doesn't come back to bite me later.