0

Using TortiseSVN you can update/commit a single directory by right clicking the directory and selecting update or commit.

I really like the branching power of git, but if I use git svn dcommit it will try to update the entire repository, which in our case has several projects in it.

So how can I commit only specific files/directories?

Thanks!

EDIT

To clarify what the SVN repos look like:

+- Trunk
|
+-+- Project 1
| |
| +- Project 1 files...
|
+-+- Project 2
| |
| +- Project 2 files..
|
+-+- My Project
  |
  +- My Project files...

And when I run git svn dcommit it tries to update everything in Project 1, 2, and My Project.

Project 1 and 2 are completely unrelated, and under development by others. How do I avoid updating/committing to the other projects? Do I simply add those dirs to .gitignore? What about if I later need to work on those other projects? Alternatively, is there a better way to use git svn to work with this type of Subversion repository?

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
  • http://stackoverflow.com/questions/3334475/git-how-to-update-checkout-a-single-file-from-remote-origin-master – Vivek Goel Jul 08 '11 at 19:33

2 Answers2

0

git add the directory you want, commit it and then do the dcommit ( after appropriate cherry picking )

I don't see how the problem of having multiple projects comes in. You will be adding the files in your concerned project and adding them. Don't compare commit in SVN to the dcommit here. Compare commit in SVN to the commit in Git. Just like how you would "right click on the directory" and commit it, git add ( or use TortoiseGit and do the same as you do in TortoiseSVN ) only that directory and commit. Then, do the dcommit.

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • actually I'm used to git, they use SVN here... and it may be a fairly poor SVN workflow. I don't think this is applicable, though, since I don't control the remote repository. – Wayne Werner Jul 08 '11 at 21:29
  • @Wayne Werner - My PS was not worded well, I have removed it. – manojlds Jul 08 '11 at 22:12
-1

When you do a git svn dcommit, each commit in your local git repo will be committed as a separate commit in to your svn remote. If you want to make it as a single commit see this question: Is it possible to make git svn dcommit result in a single svn commit? and also refer the section Rewriting History from the ProGit book and the chapter Interactive Rebasing from the Git community book.

Community
  • 1
  • 1
yasouser
  • 5,113
  • 2
  • 27
  • 41
  • Well, I didn't downvote, but I wasn't asking about doing something like `git merge --squash` followed by `git svn dcommit`. My question was asking how I could commit (or update) a `single file`. Apparently it's a fairly common practice around here to store several projects under one `trunk` folder, so to avoid checking out the entire repository (akin to trying to clone all the projects on github, say), they just checkout/in specific directories/files. I'm trying to find out if that's possible with git svn, and how to do it. – Wayne Werner Jul 11 '11 at 18:14
  • @Wayne-Werner: Do you want to maintain one repo per project? If yes, then won't certain files and/or folders have multiple state/history depending on the projects in which they are part of? Alternative is to use `.gitignore` and add those files/folders that are not part of each project. Then you need to modify it as projects gets added/removed from the svn remote. – yasouser Jul 11 '11 at 19:18
  • in our environment they store multiple projects per-repo, I've updated my question to hopefully clarify – Wayne Werner Jul 12 '11 at 17:33
  • If the projects reside in their own directory and doesn't share any files in between them, then using the `.gitignore` and having separate repo for each project makes sense. – yasouser Jul 12 '11 at 20:17