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
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