Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merge branch 'X' of URL into X

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

like image 203
tmporaries Avatar asked Dec 17 '13 17:12

tmporaries


People also ask

How do I merge a branch into another?

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.

What does merge into current branch do?

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.


1 Answers

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.

like image 160
Magnus Bäck Avatar answered Oct 03 '22 07:10

Magnus Bäck