How can i repair my git-svn mirror repository?
It is set up with git svn init ..., then github remote was added. The cron job is doing git svn rebase && git push periodically.
Everything was fine until upstream somehow "uncommited" several revisions from svn, which already was fetched into my git-svn and pushed to github. Then upstream added some new revisions to svn trunk, reusing revision numbers of "uncommited" revisions, which broke my syncronization process.
When i realized what hppened, i did git svn reset to last valid revision and commited reverse patch into git.
But since then, i can not pull upstream changes with git svn rebase, i have to do git svn fetch && git merge trunk instead, resulting in awful history.
Can i somehow tell git-svn that i will not git svn dcommit anything, that it can forget about that reverse patch commit, so git svn rebase can work like it worked before all this happened?
My investigation results: there is nothing magical in git-svn's rebase function. It is just a git svn fetch followed by git rebase refs/remotes/trunk and refs update.
In my case, all i had was to move my local tracking branch ref to the last fetched from commit.
git svn fetch
git log -1 refs/remotes/trunk
gave me latest sha1: ed0fa874ca872bc3a0101ee397f611a537e72c2a
git update-ref HEAD ed0fa87
git reset --hard
Useful resources: Pro GIT Book, Visualizing branch topology in git.
Hope, this will help someone.
Related
I organize one repository with both git and svn. svn is for collaboration. git is my own management because I like to make many many commits and branches but do not want to intefere with other people.
With say 10 git commits, I svn commit once manually. So never need to sync git => svn.
Currently when I see new svn commits, I update svn, then make a commit in git. This one git commit may include several svn commits.
I would like to do: sync every svn => git.
That is, to make EACH ONE svn commit as one git commit.
Ideally with the same commit log.
More ideally each git commit comes with a tag or extra log stating the svn commit number.
Can it be done? With git-svn?
If you were to use git svn, then you would not put your git repo inside the svn workspace.
You could git svn clone the repo, and git svn rebase at will, while making your own commit in a separate branch of that Git repo.
The svn rebase process would create one git commit per svn revision (but not with the same comment though)
I just want to know to what I am pushing when I use git svn dcommit and from what I am pulling when I git svn rebase.
Is there a commandline command I could execute that would give me that information? I just want the branch name.
Also, is there any way to see how many revisions I'm behind or ahead with git svn?
Thanks!
Try a dry run: git svn dcommit --dry-run, same for rebase.
Is there a way to ignore git-svn updates? my usual workflow:
doing stuff in my dev git branch
checking out my master
git svn rebase on master
cherry-pick from dev
git svn dcommit
checkout dev again
git merge master
the only problem with this is that after i git merge master, i do git log -n ###, and i get all the git-svn updates as well. Can i limit it just the latest git commits?
No, you can't merge master back into the dev-branch without getting the git-svn commits along for the ride.
The thing is that when you do a git svn dcommit, you actually rewrite the commits that you've cherry-picked from the dev branch. The git-svn commits are now part of your history, and it would be folly to try to get rid of them some how. If I'm guessing correctly, your dev branch is full of merge commits where your git-svn commits are re-joined with your dev-commits because they have diverged. This is messy.
That being said, I'm also unsure if your workflow is optimal. Maybe you should try this:
work work work in the dev branch
git svn rebase on master for the lastest svn changes
Now rebase these latest changes in under your work: git rebase master in dev
Now fast-forward your changes back to master: git merge dev on master
git svn dcommit on master
Now remove the dev branch. Little sense in keeping it since the commits have now been rewritten by dcommit. git branch -d dev
git checkout -b dev for the next feature/fix.
I'm looking for a command in git-svn that will show me the changes I have committed to my git repository but that aren't yet committed to the central svn repository. I'm looking for something that works like svn status, but I'm using git-svn, and unfortunately, git svn status is not a valid command.
I tried git status but it does not solve this problem, as it shows changes that haven't been committed to my local git repo.
I also tried git svn dcommit --dry-run, but it doesn't tell me which files are ready to be dcommitted - it only shows the repository URL.
Assuming the branch for the remote Subversion repository is at remotes/git-svn, run the following:
git svn fetch
The fetch will ensure that remotes/git-svn is up-to-date. (Thanks to Mark for pointing this out in a comment.)
git diff --name-status remotes/git-svn
This should show you the name and status of all the files that have been committed to git but not to Subversion, just like the svn status command.
In case you're not sure where the branch containing the Subversion remote repository is located, you can run:
git branch -a
which should produce output similar to the following:
* master
remotes/git-svn
You can probably guess from this that the remote Subversion repository is in remotes/git-svn.
You can also use
git diff git-svn HEAD -d
or if you have difftool specified:
git difftool git-svn HEAD -d
I have a bare git-svn repository and did a 'git svn fetch' on it.
Running 'git log' doesn't show the updates. I'm sure there are updates as it displayed the files changed after 'git svn fetch' and 'git svn log' shows them also.
Please note that I purposely made this a bare repo so 'git rebase' will not work.
What is the appropriate command to get the fetched changes?
A git svn fetch adds a new remote branch called remotes/git-svn (as can be seen with git branch -a).
If you make changes to the upstream svn, then run git fetch again, the changes get pulled (actually, fetched) in on this branch, not on master.
So to make git log (and everything else) work ok on the master branch you just need a merge, as you normally would have to do after a fetch (this is what git pull does, a fetch and then a merge).
Since git svn pull does not work, you will have to merge it manually. While on the master branch, run:
git merge remotes/git-svn
This will merge your master branch with the git-svn branch, making everything ok again.
So in the future, run
git svn fetch
git merge remotes/git-svn
and you will be up to date with the upstream repository once again.
Setting the ref of master's head to git-svn head as suggested by vjangus will also make this work, but you shouldn't ever be making changes in a remote branch.
Try git log git-svn - I don't have a bare repo, but I've just run git svn fetch, and standard git log gives me the current (rebased) log, but with the git-svn arg (which is the other branch besides master that is identified by git branch -a in my case) I get the log up to the fetched revision
I found the answer,
git symbolic-ref refs/heads/master refs/remotes/git-svn
Thanks to Steven Walter's comments in
http://gsocblog.jsharpe.net/archives/12