I like to remove repos that I’m not working on from my computer. I check something out, I work on it and when I’m finished I push everything and delete the folder from my computer. That way things stay tidy, it’s easy to get an overview of what I’m actually working on and I know that I don’t have any local stuff waiting to be pushed.
But…
Before deleting my local repo I want to make sure everything has been pushed to my remote. The process I go through is usually these three steps:
git st # check if there's something I haven't committed
git stash list # check if I've stashed something
git log --oneline --decorate --all # check if all branches have been pushed
I would like to simplify this. Especially the last step, which requires me to look at all my branches and see if the local and the remote ones are in sync. To be really sure, I might even have to scroll down a bit to make sure I’m not missing anything.
I’m considering writing a script for doing all of this automatically, but maybe there’s a solution out there already? (I take it I don’t have to emphasise that I want this done on the command line and not using any fancy GUIs :D)
How do you guys approach this? What’s your process for checking that you’re not forgetting anything? What tools do you use? All ideas are welcome!
To know if a local and a remote branch are in sync you need to compare the hashes of the HEAD revisions.
When you execute
git branch -v -ayou will receive a list of local and remote branches along with the hashes of the corresponding HEAD revisions:As you can easily see, develop and master are up-to-date locally and remote,
feature/Bardoesn’t exist locally andfeature/CodeContractsandfeature/Foodon’t exist remotely, so they should be pushed before deleting the local repository.