Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use git pull --rebase instead of "git stash git pull git stash pop"?

What is the difference between

git pull --rebase

and

git stash
git pull
git stash pop
like image 582
Raja Avatar asked Jan 03 '17 08:01

Raja


People also ask

Is git pull rebase same as git pull?

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 .

Should I rebase or pull?

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.

What does git pull rebase do?

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.

What is equivalent of git stash?

Shelving is the closest equivalent of git stash, as explained in Douglas Leeder's answer.


1 Answers

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

like image 190
Fletch Avatar answered Sep 22 '22 08:09

Fletch