createBranch() {
git pull
git checkout -b $1
git push --set-upstream origin $1
}
createBranchOffFeature() {
git checkout master
git pull
git checkout feature-branch
git pull
git merge master
# there are conflicts and I need to do a merge commit and push before continuing
git push
createBranch "$1"
}
I'm working on a project, and several of us are merging to master every day. My feature branch was branched off master. When I work a new story in the feature, I need to create a new branch off feature-branch, but I need to make sure that master has been merged into feature-branch before I make the new branch.
I almost always have merge conflicts in my package.json, because I have updated a package for this feature, and my coworkers have updated the same package for continued development on that package. We need to deploy my changes to that package at the same time as this feature deploys, but not before, so I can't just merge the package on that end (yet). There is another package under development as well, and I do need the updates they are making to that package. So if the merge conflict looks like:
<<<<< HEAD
7 "@proprietary/package": "/@example/package-110-feature.tgz",
8 "@proprietary/package2": "/@example/package2-1.0.0.tgz",
=====
7 "@proprietary/package": "/@example/package-113.tgz",
8 "@proprietary/package2": "/@example/package2-1.0.2.tgz",
>>>>> master
Then I keep my package and their package2, and delete the other 5 lines.
Sometimes there are other conflicts as well, so generally I am going to have to fix merge conflicts manually, and then I perform the git commit, and at that point, I want my function to pick back up and finish making the branches.
Is this possible? If so, what do I need to do on the commented line of the function in order to do it?
Right now I'm using read
on that line to wait for any input.
It works fine, but because I've been testing iterative versions of this function, there are no longer any merge conflicts, so it's just pausing after the merge says "Already up-to-date". I press Enter and it continues as I expect.
Will this work if I type git commit
there instead?
Could I do something like:
read
git commit -am "merging master into feature"
But what if there wasn't a merge conflict, because I finished a small story before anyone else merged to master? Can I conditionally do the git commit
?
createBranch() {
git pull
git checkout -b $1
git push --set-upstream origin $1
}
createBranchOffFeature() {
git checkout master
git pull
git checkout feature-branch
git pull
git merge master
# there are conflicts and I need to do a merge commit and push before continuing
git push
createBranch "$1"
}
I'm working on a project, and several of us are merging to master every day. My feature branch was branched off master. When I work a new story in the feature, I need to create a new branch off feature-branch, but I need to make sure that master has been merged into feature-branch before I make the new branch.
I almost always have merge conflicts in my package.json, because I have updated a package for this feature, and my coworkers have updated the same package for continued development on that package. We need to deploy my changes to that package at the same time as this feature deploys, but not before, so I can't just merge the package on that end (yet). There is another package under development as well, and I do need the updates they are making to that package. So if the merge conflict looks like:
<<<<< HEAD
7 "@proprietary/package": "https://gitlab.proprietary/@example/package-110-feature.tgz",
8 "@proprietary/package2": "https://gitlab.proprietary/@example/package2-1.0.0.tgz",
=====
7 "@proprietary/package": "https://gitlab.proprietary/@example/package-113.tgz",
8 "@proprietary/package2": "https://gitlab.proprietary/@example/package2-1.0.2.tgz",
>>>>> master
Then I keep my package and their package2, and delete the other 5 lines.
Sometimes there are other conflicts as well, so generally I am going to have to fix merge conflicts manually, and then I perform the git commit, and at that point, I want my function to pick back up and finish making the branches.
Is this possible? If so, what do I need to do on the commented line of the function in order to do it?
Right now I'm using read
on that line to wait for any input.
It works fine, but because I've been testing iterative versions of this function, there are no longer any merge conflicts, so it's just pausing after the merge says "Already up-to-date". I press Enter and it continues as I expect.
Will this work if I type git commit
there instead?
Could I do something like:
read
git commit -am "merging master into feature"
But what if there wasn't a merge conflict, because I finished a small story before anyone else merged to master? Can I conditionally do the git commit
?
1 Answer
Reset to default 0You can do something like :
...
git pull
if ! git merge master; then
read -p "Try to resolve conflicts in another bash session, and type Enter once done"
fi
git push
...
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745202736a4616423.html
git merge --no-commit
to start with, then whether there is a conflict or not,git commit
will complete the merge. – matt Commented Feb 12 at 20:56if git merge master
and take actions depending the result of the merge ? – Philippe Commented Feb 12 at 21:35git merge master
unconditionally. To make it conditional, you would need to capturestdout
(stderr
?) and analyzed that string. – Sergey A Kryukov Commented Feb 12 at 23:03