How to track local / set changes with git-svn?

I want to have files that I am tracking in a local git repository that do not fall into the central svn repository when I run git-svn dcommit. I often have long-term changes to the local file in files tracked in the repository. Sometimes this is for debugging code. I also have project IDE files that I would like to track. With a simple old svn, I would simply put these files on the change list, designated as β€œXYZ: DO NOT CHECK IN,” and then just manually deal with the problem when I really have the changes I need to make.

Ideally, I would like to check my changes in my main branch, but install something that prevents these specific changes from being propagated to the svn repository. I would use git and git-svn in the usual way, but some commits are never pushed. Obviously, I can do it manually every time I do a fix, but this is a pain.

I reviewed and discarded a couple of things. I do not want to exclude these files, because sometimes I need to make changes that dcommitted MUST do. In addition, I would like these files to appear in any local branches that I create, for example, in the case of IDE files. However, I cannot isolate these changes to one branch, because I want them to be in each branch, as in IDE files. It seems like something like guilt or stgit can do what I want, but this is not obvious as they add their own level of complexity on top of git, which I am still learning.

+7
git svn git-svn
source share
5 answers

I'm a little new to git, but I would recommend using a separate main and working branch in the local git repository.

Add your non-SVN files to the working branch only. As a rule, all code changes in a working branch. When non-SVN files change, add them using a unique commit and set the commit message prefix (that is, "local:" or "private:"). When you are ready to transfer SVN, follow these steps:

  • Show the commit log to add to SVN:

    git co working git cherry master 
  • Add all upstream commits to the main branch, ignoring "private". Repeat this step until all upstream commits are in the main.

     git co master git cherry-pick <SHA1> 
  • Click on the SVN repo:

     git svn rebase git svn dcommit 
+2
source share

My current solution to the problem is to use stacked git (stg) and support these local changes as separate patches. When I need dcommit in Subversion, I do

 stg pop # naming the patches that should not be commited stg commit # the rest of the patches to commit git svn dcommit stg push # naming the patches that are used locally 

The good thing to keep these as separate patches is that I can easily have patches that modify my unit tests to test different databases. So I usually test Oracle, but if I want to test Derby, I do

 stg push local-mods-derby ant tests stg pop 

or if I want to test PostgreSQL, I ran

 stg push local-mods-test-postgresql ant tests stg pop 

Here, "local-mods-derby" and "local-mods-test-postgresql" are the names of the patches.

So saving individual work patches is very easy with stg.

+2
source share

Do you think that you are not working on the main branch?

If you save your changes to the local git branch, you can periodically merge or cherry-pick only the necessary changes to the svn tracking branches. Go to the tracking branches, run dcommit. Then go back to your local branch and reinstall it.

If you need changes in several branches, leave them all from one branch point. Save this branch as master +, changing it with a reboot. Then, for all of your other branches, simply undo that base branch.

+1
source share

You might want to consider how to use this wallet.

 git-stash - Stash the changes in a dirty working directory away 

This may not be enough for what you are describing.

0
source share

I did some research and came up with an opportunity that could do this: 2 git repositories pointing to the same directory. The GIT_DIR environment variable stores the name of the local repository directory. If unset, git defaults to -git, but it could be anything.

What I could do is have one repository in .git, which appears in my Subversion repository. This is a common case. Then I could have another repository in .localgit. Each repository must be configured to ignore files managed by another. It is easy with! to deny the drawings.

When I make changes to the local files that I want to check, I either change my GIT_DIR environment variable or use the command line argument - git -dir. If I have my exceptions / ignored properly configured, I don’t have to worry about collisions. Obviously, there is some overhead to keep this update, but I can write a shell script that adds the file to one repo exception when the file is added to another. In addition, this overhead occurs only once for each file, and not for each commit, as is the case with a multi-branch offer.

If I wanted to make it simpler, I could use a naming convention, but I can also do it in every single file, since the number of local files will almost certainly be in the form of single digits (otherwise I am something wrong) .

One of the sides that I see with this approach is that I would not be able to deploy and store the files and the reset files locally just like the files in the SVN repository. My change for them is likely to be asynchronous with respect to my main changes, so I don't think that would be a significant problem in practice. I could also write wrappers for those functions that were aware of several repositories. Also, I should be more explicit when managing local files, but pretty much any situation would have to deal with this if several repositories weren’t built into git.

0
source share

All Articles