I want to create git feature branch using teamcity and also merge it to dev using teamcity. Is it possible and how?
1 Answers
Just like do it in shell. Except you should specify repository directory by git -C /path/to/repository <command>
.
First you need ensure the working directory turn into what you expected. So just use git reset --hard
to ignore potential errors.
Second you need carefully deal the merge operation, it needs success. So you should choose how to resolve conflict. git merge help
has explained in MERGE STRATEGIES section. I suggest to use recursive theirs
to preserver feature branch changes.
Example:
git -C /home/git/test checkout master
git -C /home/git/test reset --hard origin/master
git -C /home/git/test checkout -b newfeature
do some change
git -C /home/git/test add -A .
git -C /home/git/test commit -m "Do some change"
git -C /home/git/test checkout master
git -C /home/git/test merge -s recursive -X ours newfeature
git -C /home/git/test push
![](../../users/profiles/1139071.webp)
- 329
- 2
- 4
-
Hi Thanks for the reply. But i want to achieve this through teamcity. Any idea how to do this? – IAmAProgrammer Apr 12 '17 at 06:49
-
Add build step `command line` in TeamCity. And copy paste these comand. – networm Apr 12 '17 at 13:43
-
Ok what about creating the feature branch? Example, If I have some 5 repos in project, and I want to create a feature branch, then from Teamcity through any configuration/script I should be able to create same feature branch in all the repos at once. – IAmAProgrammer Apr 12 '17 at 16:25
-
The first three lines of code is about to create feature branch. You need to know where feature branch starts and then create branch based on that, like: `git checkout -b newfeature basedCommitOrBranch` – networm Apr 13 '17 at 21:53
-
Just create new feature branch for every repository. After that run any script you use. Why do you need create feature branch? I think continuous deploy doesn't need that. – networm Apr 13 '17 at 22:04