When I and my colleague work on the same git branch, each of us sees a strange commit with message
"Merge branch 'X' of URL into X"
where X - the same branch.
after pull has been performed (and new changes came from remote). I said "strange" because I previously work with SVN, and this process in SVN is transparent - SVN doesn't create a commit when I perform "svn update" in order to obtain changes from server.
Is it possible to avoid such commits? They litters log history...
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
Merging is Git's way of putting a forked history back together again. The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch. Note that all of the commands presented below merge into the current branch.
Instead of merging upstream changes into your own respective branches, rebase your branches against the upstream prior to a push. Use the --rebase
option to git pull
or set the branch.<name>.rebase
option in ~/.gitconfig to enable that option by default. If you consistently do this you'll get a nice linear history.
Rebasing branches is something that should be done with caution and with an understanding of how the process works. Specifically, don't rebase commits that have been published, i.e. left your own personal workspace via a push. Up until that happens, feel free to rework your commits by rebasing, squashing or whatever you need to do before they're fit for being published to the world.
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