top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to automatically merge changes from many branches in GIT?

+2 votes
427 views

One practice of using git to have one feature per branch.

Let's say a developer has worked on many small features in many branches. Then he sends one pull request to the central (not controlled by him) for each feature he has developed. While he is waiting for all the features be merged into the central repository, he needs to use all these feature locally.

To do so, he may need to merge the changes in these branches to his local master branch. But this can be tedious when he has many branches.

Is there a way to somehow setup a branch so whenever something is committed to the branch, the changes will also be simultaneously committed to the local master branch? By this way, the develop can avoid having to merge changes from many branches.

posted Apr 2, 2015 by Amit Parthsarthi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

If by tedious you mean resolve the same merge conflict multiple times, then rerere (http://git-scm.com/blog/2010/03/08/rerere.html ) may solve your problem.

If you want to go the way you described, you will have to implement some client side hooks, which cherry pick your new commits on another branch. This, however, may introduce merge conflicts; I dont know how will hooks tolerate this.

answer Apr 2, 2015 by Daler
Similar Questions
+1 vote

I have a large Git project which I would like to dissect into subprojects with their own repositories. Git subtrees are ideal for this task: I first

  • create a branch with the contents of only one subfoldergit subtree split -P -b

and then

  • pull this branch into another repository.

For a transitional phase, I would like to have the subprojects read-only and sync them from master. The question is how to organize this. For every commit to master, I could of course perform the above procedure repeatedly for all subprojects, but this seems less then ideal since it does all the work all over again.

Is there a way to merge master into the subtree branches?

+1 vote

At some point I added a large file into a git repository. It now exists on multiple branches, possibly with some changes to it. I'd like to remove it from git, but leave its current form (say the one on the master branch) on the file system.

I tried (on a dummy git archive)

git filter-branch --index-filter 'git rm --cached --ignore-unmatch bigfile' master branch1 branch2

That, however, does not leave a copy of bigfile on the file system.It isn't clear to me why not, though the description of the --tree-filteroption to filter-branch (I'm using the --index-filter option, but is is "similar") states:" (new files are auto-added, disappeared files are auto-removed ... )".
Is there a direct way to do what I want, with git? I've found similar requests;none of the responses point out that the above command actually deletes the file from the file system.

0 votes

I created a dump from a repository. git bundle list-heads prints all the refs I meant to add. The problem is that after extracting the dump with git bundle unbundle the target repository doesn't contain any branches (git branch -a prints nothing). How can we extract a dump so that the branches are also restored?

+1 vote

Perhaps my git workflow is wrong.

I have committed numerous times in order to complete a task, but when the code is to be reviewed, Id like to show a non-contiguous view of my changes, which do not include the commits other developers have made. Is this possible?

Or should I be creating a branch and showing the differences from the master and my branch when it comes to a code review?

+3 votes

I opened a file and wrote a piece of code.
When I ran $git diff
it is showing the differences what I did.
Can I get back the file (version) which is in remote branch ?
Is there any command ?

...