Git merge auto-add all new lines -
//edited clarity
is there way actually, or theoretically merge 2 commits , keeps of different content between them.
suppose have master branch single file called index.js
//master //index.js alert('a'); alert('z'); two branches off of master this:
//branch 1 //index.js alert('a'); alert('b'); alert('z'); //branch 2 //index.js alert('a'); alert('c'); alert('z'); the ideal automerge result merging branch 1 branch 2 be
//branch 2 //index.js alert('a'); alert('b'); alert('c'); alert('z'); is there anyway achievable?
your diagrams confusing, , don't justice point trying make. basic question can preserve commits in 2 feature branches such appear in master branch whence created. git has tool doing this, , called git rebase. consider following scenario:
master: -- b -- c branch1: -- b -- d branch2: -- b -- e in example, both branch1 , branch2 branched off master @ commit b, , both have 1 additional commit since then. following command rebase branch1 on master, thereby bringing in changes master while preserving commits:
git checkout branch1 git rebase master now diagrams this:
master: -- b -- c branch1: -- b -- c -- d' branch2: -- b -- e now branch1 can pushed onto master using git push origin branch1:master leaving diagrams looking this:
master: -- b -- c -- d' branch1: -- b -- c -- d' branch2: -- b -- e rebasing can done branch2 leave diagrams looking this:
master: -- b -- c -- d' -- e' branch1: -- b -- c -- d' branch2: -- b -- c -- d' -- e' now master branch has commits both branches.
Comments
Post a Comment