How do I change ignore-paths on an existing git-svn repo? - git-svn

I have an already existing git-svn repo with an ignore paths in my .config file that looks like this:
ignore-paths = ^(?!(Path1/Proj1|Path1/Proj2|Path2/Proj3))
This works well.
Someone added a new project in svn that I now need in my git repo.
If I change ignore-paths to what's below and issue a fetch or a rebase, I never see Path2/Proj4
ignore-paths = ^(?!(Path1/Proj1|Path1/Proj2|Path2/Proj3|Path2/Proj4))
In the past, I've always given up and blasted away my git repo and recreated it. Is there a better way?

After editing the ignore-paths you need to
git svn reset -r <n> -p # where <n> is the SVN revision where the new path was added.
git svn fetch
git rebase # or reset
Reference git-svn(1):
reset
Undoes the effects of fetch back to the specified revision.
This allows you to re-fetch an SVN revision. Normally the
contents of an SVN revision should never change and reset
should not be necessary. However, if SVN permissions change,
or if you alter your --ignore-paths option, a fetch may fail
with "not found in commit" (file not previously visible) or
"checksum mismatch" (missed a modification). If the problem
file cannot be ignored forever (with --ignore-paths) the only
way to repair the repo is to use reset.
Only the rev_map and refs/remotes/git-svn are changed (see
$GIT_DIR/svn/*\*/.rev_map.* in the FILES section below for details).
Follow reset with a fetch and then git reset or git rebase to
move local branches onto the new tree.

Related

reconcile git svn after git filter-branch

I am attempting to convert a SVN repository into git. The SVN repository is being actively used, while we work out the details of converting.
I followed all the guides and created an author mapping file and cloned the SVN repository.
> git svn clone https://host/svn/Project --trunk=trunk -A svn-author-map.txt
Concurrently with this switch to git, I would also like to atone for some of the sins of the SVN past (stored passwords, etc). However as soon as I alter any of the history with git filter-branch or BFG, I seem to break the ability to incorporate any updates from SVN.
> git svn fetch --fetch-all
fatal: Invalid revision range [sha from clone]..refs/remotes/trunk
Is there a way to refresh the git-svn ids to the post filter-branch ids? Or is there no going back after changing any history?
If you edit the history after conversion, then maintaining the link can become tricky.
I guess the best options are either do one-time conversion (make svn source read-only, fully switch to edited git repo), or just keep the history as is and change the leaked passwords instead.

history not preserve while move svn to GIT (for svn Move folders)

I have an SVN project with a structure as specified below:
PROJECT > trunk, branches, tags, subproject1, subproject2, release notes
I have restructured the project through the SVN MOVE command so it looks like:
trunk, branches, Tags. (moved the folders into trunk).
I'm able to see history preserved as I moved through SVN MOVE command.
Now, I have migrated the SVN repository to GIT through below command,
$ git svn clone --stdlayout --authors-file=authors.txt file:///svnrepos/local-svn/PROJECT project.git
NOw, In the GIT repository, I am not able see the history for moved folders and it only shows me last "svn move" command history. I can see history for all other files which are not moved.
Please let me know your comments.
Thank You.
SVN Move will not be able to preserve the history while moving to GIT as it will consider as new directory entry commit in GIT.
there is require to use SVN-DUMP-RELOC which will restrcutre the directory in SVN DUMP file instead of repository.
Please follow the steps mentioned in below link for windows machine:
svn-dump-reloc use in windows command prompt
Thanks

Git merge with overwriting local changes [duplicate]

In Git, during a merge, is there a way that we can tell git to discard local changes in case of a conflict and apply the changes from the merged branch?
I mean if there is a way, then we can do merges like branch merges without conflicts.
Before trying to merge, you can discard the local changes yourself git reset --hard HEAD.
You can replace HEAD by whatever commit hash you want.
This will bring you the the clean state of the commit you're actually on, and you'd lose all your changes.
If you want to keep them, you can stash them before with git stash, or move them to another branch:
git checkout -b new_branch
git add .
git commit -m "My awesome commit"
git checkout - # will bring you back to the last branch you were in
If you want to ignore all local changes, and an additional merge commit you want to just move your branch to the remote HEAD.
git log --oneline origin/master
# assume the first sha is bbdfa17
git reset --hard bbdfa17
Now you are at the tip of the tree with no merge commits.
It sounds like you want to read about the merge strategies 'theirs' and 'ours'. When merging you can specify that either your current branch (ours) or the remote branch (theirs) is the correct one.

How can you use git-svn to clone parts of an SVN repo, but still get all the branches

Is there any way to use git-svn to clone only some folders of an SVN repo structure. I'm trying to clone a repo that has some crazy big binary files and a number of subfolders that are just plain useless. I've tried using the --ignore-paths option, but my clone seemed to just stall out doing nothing for an extremely long time. Have any of you managed to make --ignore-paths work? I can't find much on the webs where anyone else is running into this. Maybe I'm the only one.
We've used the "ignore-paths" feature to ignore certain directories in a svn repo:
[svn-remote "svn"]
ignore-paths = ^(((branches|tags)/[^/]+|trunk)|)(huge/|mobile/)
This config ignores the "huge" and "mobile" subdirs of the repository in trunk, all branches and all tags.
Perhaps you can illustrate the structure of your Subversion repository to make it easier for us to suggest some solutions.
Are you trying to git svn clone the entire repository from the root-url? Have you tried cloning smaller parts of the repo, and then perhaps grafting several clones together?
The most success I've had here is to manually create branches in git that mirror the SVN remote repository when necessary. The process has been the following:
Update .git/config file with:
[svn-remote "svn-branch-alias"]
url = http://svn/branches/crazybranchname/craziername/url/
fetch = :refs/remotes/git-branch-name
From the command line type: git svn fetch 'svn-branch-alias' to collect the SVN branch data into your local git repo.
Then type: git checkout 'git-branch-name' to go into a headless mode.
Finally type: git checkout 'my-local-git-branch-name' to create move head to the latest submission in that branch and create a local branch alias you can use.
You can now commit and dcommit as usual and still switch between various local git branches and your manually created SVN mirrors using the usual mechanisms.

How to recover from an unwanted rename using git-svn: "Transaction is out of date"

I'm using git-svn. I've moved file 'A' to 'B' and I'm up to date with the svn HEAD (using git svn rebase). I can commit all other changes without problems. Now I've decided that I want to move 'B' back to 'A' and commit that change.
When I do the move and commit to my local master it works fine, but I get the following when doing a git svn dcommit:
Transaction is out of date: Out of date: 'A' in transaction '3652-1' at /opt/local/libexec/git-core/git-svn line 570
So I tried to copy and delete in a separate commit which resulted in:
Item already exists in filesystem: File already exists: filesystem '/usr/svn/db', transaction '3652-1', path 'A' at /opt/local/libexec/git-core/git-svn line 4735
I've recovered from this situation with plain svn by using the workarounds like the one described in the documentation, but I don't know how to recover with git-svn. What is going on and how do I fix it?
Removing .git/svn did not work for me. Instead, here's how I resolved:
Deleted the offending directories from the repository (But I'm not sure that this is necessary. In hindsight I think I could have skipped this step)
git svn rebase
During the rebase, there were some conflicts. For each conflict, I resolved the conflicts in text editor, then used git add <file-in-conflict> and then git rebase --continue
After rebase completed successfully, git svn dcommit ran successfully!
I can't claim to understand what's really going on under the hood in git-svn in this case (although the underlying SVN issue makes perfect sense). My usual strategy when git-svn gets confused somehow is to blow away the .git/svn metadata directory (as in this post). This almost always saves me from odd synchronization issues between the git and SVN repositories.
It happened with me when I interrupted the dcommit process.
Follow these steps to recover from error:
git svn rebase
You will get conflicts in files. Resolve the conflicts & then git add filename (in which conflict occurred) for each file.
Now do git svn dcommit. It will be pushed to remote successfully.