I have created a branch out of develop branch. Now to get develop branch changes into my feature branch should I use git rebase origin/develop or git pull and why?
Asked
Active
Viewed 174 times
1
-
2Possible duplicate of [What's the difference between 'git merge' and 'git rebase'?](https://stackoverflow.com/questions/16666089/whats-the-difference-between-git-merge-and-git-rebase) – Tim Biegeleisen Jan 09 '18 at 04:21
-
1The question should be _Should I use git rebase or git merge?_ The answers is simple. It's all up to you. Merge will make one addition commit after applying changes from develop brunch. With rebase changes will migrate without any extra commits – keipa Jan 09 '18 at 05:09
1 Answers
0
As long as your branch has not been pushed before, you can rebase it on top of the updated develop branch (origin/develop
)
git fetch
git checkout yourBranch
git rebase origin/develop
See more in my 2009 answer
The fact that you have branched locally from the local branch develop
does not prevent you to rebase on top of an updated develop
branch: that is the one from the remote repo: origin/develop
.
You would rebase on top of develop
only if you were the only one working on that repo, and if you added yourself local commits to that local develop
branch.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
Thanks - please confirm what git pull will do? Note that I have branched from develop and not origin/develop. – Programmer Jan 09 '18 at 07:50
-
@Prakash pull would fetch then merge origin/master, from your GitHub repo, which includes the file(s) added at the repo creation: those files would be merged/assed to your local repo, allowing you then to push back only your changes. – VonC Jan 09 '18 at 07:52
-
@Prakash you usually rebase on top of origin/develop, unless you added yourself commits to the local develop branch. – VonC Jan 09 '18 at 07:53