我想学习如何在 svn 存储库中使用 git。
我遵循以下手册:http://git-scm.com/book/en/Git-and-Other-Systems-Git-and-Subversion
我在文件中进行了一些更改。他们中的一些人上演了,其中一些没有:
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: CHANGES.txt
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: CHANGES.txt
#
根据手册,我首先将暂存更改提交到我的本地存储库中:
$ git commit -m "new"
[master 21bf2bd] new
1 file changed, 1 insertion(+)
现在我只有未阶段的更改,我想像将来提交一样生活:
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: CHANGES.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
我想将本地提交推送到上游 svn:
$ git svn dcommit
CHANGES.txt: needs update
update-index --refresh: command returned error: 1
为什么我做不到?
我什么时候可以使用"dcommit",什么时候不能?我显然缺乏这些信息,我无法在谷歌或手册页中找到更多描述。
当你做dcommit时,你不能有任何未提交的更改。
要暂时隐藏您的修改,请使用 git stash
。然后提交git svn dcommit
,最后用git stash pop
弹出存储,以再次启用您的修改。