I am currently working in a team of two using a git repository. In that environment, you want to have a clean history which can only achieved with the
git rebase command. Using this small code snippet, I can fetch the changes online, rebase my code according to the changes fetched and push my changes automatically. If an error occurs, the command will abort.
git fetch && git rebase && git push
However, this does not work if you still have files locally which are not committed, e.g. some changed files in your working directory. For this purpose, the stash can be used. The
git stash is a stack for storing changes temporarily. By saving the uncommitted changes before fetching and rebasing, you can integrate them back afterwards.
git stash save && git fetch && git rebase && git push && git stash pop
What git tricks do you use?
PS: The commands above work on *nix and Windows.