Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does git pull --rebase origin master means?

Tags:

git

github

I want to know what are the advantage of --rebase option in git pull command when and where we have to use this option and when we dont have to use this option ?

like image 772
Nitin9791 Avatar asked Aug 30 '25 18:08

Nitin9791


1 Answers

You should use git pull --rebase when

  • your changes do not deserve a separate branch

Indeed -- why not then? It's more clear, and doesn't impose a logical grouping on your commits.


Ok, I suppose it needs some clarification. In Git, as you probably know, you're encouraged to branch and merge. Your local branch, into which you pull changes, and remote branch are, actually, different branches, and git pull is about merging them. It's reasonable, since you push not very often and usually accumulate a number of changes before they constitute a completed feature.

However, sometimes--by whatever reason--you think that it would actually be better if these two--remote and local--were one branch. Like in SVN. It is here where git pull --rebase comes into play. You no longer merge--you actually commit on top of the remote branch. That's what it actually is about.

Whether it's dangerous or not is the question of whether you are treating local and remote branch as one inseparable thing. Sometimes it's reasonable (when your changes are small, or if you're at the beginning of a robust development, when important changes are brought in by small commits). Sometimes it's not (when you'd normally create another branch, but you were too lazy to do that). But that's a different question.

Link To Follow

like image 138
Pankaj Singhal Avatar answered Sep 02 '25 12:09

Pankaj Singhal