How git merge the remote branch to local branch ?

802    Asked by KevinRose in Data Science , Asked on Jul 14, 2021

I have a local branch of a project ("configUpdate") that I've forked from somebody else's project and I've done a load of changes on it and would like to merge the changes they've made into my local branch.

I've tried

git pull --rebase origin configUpdate

but it hasn't grabbed the latest changes - how can I merge the two? (also for bonus points what did I do with the pull --rebase command?)

Answered by James WILLIAMS

For this question, you can do:

git fetch
git rebase origin/master

 This would help you to resolve your query.

Additional information:

git merge branchname will take new commits from the branch(branchname), and add the commits to the current branch. It can automatically add a "Merge" commit on top.

git rebase branchname takes new commits from the branch(branchname) and insert those commits "under" your changes.

It will modify the history of the current branch such that it is based on the tip of branchname.

git pull is similar to git fetch; git merge origin/master.

git pull --rebase and git fetch are similar; git rebase origin/master.

example:

You start working on a new feature.

when you're ready to push your changes, several commits have been pushed by other developers already.

If you use git pull, your changes will be buried by the new commits, in addition to an automatically-created merge commit.

If you use git pull --rebase instead, git will fast forward your master to upstream, then apply your changes on top.



Your Answer

Interviews

Parent Categories