svn master branch back to trunk

I'm not sure how I got into this state, but my master branch on my local git-svn repo seems to be pointing to the remote UAT branch.

git status
# On branch master nothing to commit (working directory clean)
git svn dcommit Committing to https://svn...com/MyRepo/branches/UAT ...

how do I fix this?


I think what you're trying to fix is that your local "master" branch is based on the remote UAC branch, as opposed to the remote trunk. If you're happy to lose your commits, you can simply run the below, which will checkout the trunk and then move the master branch to your current point.

git checkout remotes/trunk
git checkout -B master

If you don't want to lose your commits, git rebase is your friend. Use the below:

git rebase $(git merge-base remotes/UAC master) master --onto remotes/trunk

This works out the common parent of the UAC branch and the local master branch, makes all the commits from there to the tip of the master branch onto the trunk, then moves the master branch to point there.


One way would be to rename the current master branch and to checkout origin/trunk as (new) master branch.

git branch -m master uat
git checkout origin/trunk master

If you need you can now cherry-pic commits from the uac branch to master (I would use gitk --all to help me with this)

A little more complex problem: Rename master branch for both local and remote Git repositories

链接地址: http://www.djcxy.com/p/15826.html

上一篇: Sourcetree / git不显示关闭的远程分支

下一篇: svn主分支返回主干