What is the difference between
git pull --rebase
and
git stash
git pull
git stash pop
This two git commands are not interchangeable. Git pull downloads the newest changes from the remote repository and applies the changes to your local repository. Generally, git pull is git fetch and git merge. Rebasing on the other hand can be a replacement for git merge .
It is best practice to always rebase your local commits when you pull before pushing them. As nobody knows your commits yet, nobody will be confused when they are rebased but the additional commit of a merge would be unnecessarily confusing.
Git pull rebase is a method of combining your local unpublished changes with the latest published changes on your remote. Let's say you have a local copy of your project's main branch with unpublished changes, and that branch is one commit behind the origin/main branch.
Shelving is the closest equivalent of git stash, as explained in Douglas Leeder's answer.
To answer the question in the title: No, but you can use this to achieve what you want in one command:
git pull --rebase --autostash
More info: https://cscheng.info/2017/01/26/git-tip-autostash-with-git-pull-rebase.html
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