If I am working on my branch, branch1 and then I push some commits while my team member was also working on branch1--when it comes time for my team member to push his changes, he's now behind.
What is the easiest way for him to get my most recent commits, and attempt to merge his changes with mine? Let's assume he has already committed his changes before realizing this error.
I thought you'd do:
git pull origin/branch1 && git merge origin/branch1
but that doesn't seem to work at all.
I believe you'd do a rebase, but I'm unsure of the process; all anyone talks about is doing rebase with master--but I don't want to do anything with master at this point.
git pull origin/branch1 && git merge origin/branch1
git pullgit pull is actually an alias to those 2 commands: git fetch + git merge so your second part of the command is useless.
# Update your local repo with the latest code:
git fetch --all --prune
# Merge the changes (you already did a pull)
git merge origin branch1
OR:
# grab & merge the latest changes into your current branch
git pull origin branch1
rebaseIf you want your changes to be on top of the other changes then you can use the --rebase flag when pulling the content.
# As before - update your local repo with the latest code:
git fetch --all --prune
# Merge the changes with the rebase flag
git pull --rebase origin/branch1
Image src: http://blogs.atlassian.com/
You have those config which you can set:
rebase.autoStash + pull.rebase
rebase.autoStashWhen set to true, automatically create a temporary stash before the operation begins, and apply it after the operation ends.
This means that you can runrebaseon a dirtyworktree.However, use with care: the final stash application after a successful
rebasemight result in non-trivial conflicts. Defaults to false.
pull.rebaseWhen true, rebase branches on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run.
git config pull.rebase true
git config rebase.autoStash true
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