简体   繁体   中英

When git svn dcommit can be used?

I want to learn how to use git with svn repository.

I follow this manual: http://git-scm.com/book/en/Git-and-Other-Systems-Git-and-Subversion

I make some changes in my file. Some of them staged, some of them not:

# 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
#

According to the manual I first commit staged changes into my local repository:

$ git commit -m "new"
[master 21bf2bd] new
 1 file changed, 1 insertion(+)

now I have only unstages changes, which I want to live like it is for the future commits:

$ 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")

And I want to push local commits upstream to svn:

$ git svn dcommit         
CHANGES.txt: needs update
update-index --refresh: command returned error: 1

Why can't I do it?

When can I use "dcommit" and when I can't? I clearly lack this information, and I wasn't able to find more description in google or man pages .

You can't have any non-commited changes when you do dcommit.

To temporarily hide your modifications, use git stash . Then commit with git svn dcommit , and finally pop the stash with git stash pop to enable your modifications once again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM