Я хочу оформить проект SVN, создать ветку на удаленном SVN и соответствующую локальную ветку Git.Тогда я хочу сделать некоторые изменения.Изменения должны быть отражены в обеих ветках - SVN и Git, так как некоторые люди работают в SVN, и они должны видеть ветку task3
.
Сценарий ниже делает это успешно:
#!/bin/bash
DIR=/tmp/svn-experiments # Directory for experiments
rm -rf "$DIR"
mkdir "$DIR"
cd $DIR
rm -rf svnrepos
svnadmin create svnrepos
# Create a project with standard SVN-project folder structure:
mkdir -p project/{trunk,branches,tags}
cd project/trunk/
echo "Hello" > readme.txt
echo "Log entry 1" > day.log
# Import the project into repository
svn import -m "Project import into repository" "$DIR"/project file://"$DIR"/svnrepos/project
svn log file://"$DIR"/svnrepos/project
# Simulate two users and conflict
# Developer 1 (svn) creates working copy, branch:
svn co file://"$DIR"/svnrepos/project "$DIR"/developer_svn1
cd "$DIR"/developer_svn1
svn copy file://"$DIR"/svnrepos/project/trunk file://"$DIR"/svnrepos/project/branches/task1 -m "Create a branch for task 1"
svn update
cd "$DIR"/developer_svn1/branches/task1
sed -i -r 's/(.*)/\1 world/g' readme.txt
svn commit -m "Change from developer_svn1"
svn update
# Developer 2 (svn) creates working copy, branch:
svn co file://"$DIR"/svnrepos/project "$DIR"/developer_svn2
cd "$DIR"/developer_svn2
svn copy file://"$DIR"/svnrepos/project/trunk file://"$DIR"/svnrepos/project/branches/task2 -m "Create a branch for task 2"
svn update
cd "$DIR"/developer_svn2/branches/task2
sed -i -r 's/(.*)/\1 Russia/g' readme.txt
svn commit -m "Change from developer_svn2"
svn update
# Currently creates a remote SVN branch 'task3' and the corresponding local Git branch 'task3'
# Commits to local and remote
# TODO How to merge changes in 'task3' into 'trunk' of SVN by using Git only?
git-workflow() {
# Developer 3 (git) creates working copy, branch:
git svn clone -s file://"$DIR"/svnrepos/project "$DIR"/developer_git1
cd "$DIR"/developer_git1
git svn -m "Create a branch for task 3" branch task3 # The branch will be created on SVN
git branch task3 remotes/origin/task3
git checkout task3
sed -i -r 's/(.*)/\1 Germany/g' readme.txt
git add -u
git commit -m "Change from developer_git1" # Commit in local Git branch
git svn dcommit # Commit to the corresponding SVN branch
}
Но я не могу понять, как я могу объединить изменения в локальной ветке Git task3
в trunk
SVN.
Я пробовал следующее:
/tmp/svn-experiments/developer_git1$ git branch -a
master
* task3
remotes/origin/task1
remotes/origin/task2
remotes/origin/task3
remotes/origin/trunk
/tmp/svn-experiments/developer_git1$ git checkout master
Switched to branch 'master'
/tmp/svn-experiments/developer_git1$ git show-ref
7c4844a091dd649a7ffd15a3dac07da927fca426 refs/heads/master
2e0964804ba1f3f84baaba8ade0934899ea2a69d refs/heads/task3
6e42f27d10ca25a0189b94d8dc1ada96a38f494b refs/remotes/origin/task1
7992320699f10f77062c2c7fa9c78edeec2ce01b refs/remotes/origin/task2
2e0964804ba1f3f84baaba8ade0934899ea2a69d refs/remotes/origin/task3
7c4844a091dd649a7ffd15a3dac07da927fca426 refs/remotes/origin/trunk
/tmp/svn-experiments/developer_git1$ git merge task3
Updating 7c4844a..2e09648
Fast-forward
readme.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
/tmp/svn-experiments/developer_git1$ git show-ref
2e0964804ba1f3f84baaba8ade0934899ea2a69d refs/heads/master
2e0964804ba1f3f84baaba8ade0934899ea2a69d refs/heads/task3
6e42f27d10ca25a0189b94d8dc1ada96a38f494b refs/remotes/origin/task1
7992320699f10f77062c2c7fa9c78edeec2ce01b refs/remotes/origin/task2
2e0964804ba1f3f84baaba8ade0934899ea2a69d refs/remotes/origin/task3
7c4844a091dd649a7ffd15a3dac07da927fca426 refs/remotes/origin/trunk
/tmp/svn-experiments/developer_git1$ git svn dcommit
Committing to file:///tmp/svn-experiments/svnrepos/project/branches/task3 ...
Как заставитьmaster
указать на trunk
и зафиксировать там?