Git Notes — svn Migration, Undoing Local Commits, rebase vs merge
Contents
Three separate git notes, collected into one page — from the commands used while moving off svn, through to working out what rebase actually does.
Migrating from svn to git
| |
users.txt maps svn accounts to git accounts. This is the command that builds it, but
it never worked for me — probably a missing perl.
| |
Handling the ignore file
| |
Pointing at the remote
| |
Converting tags
svn tags arrive as remote branches in git. This turns them into real tags.
| |
Converting branches
| |
Pushing
| |
GitLab backup and restore
| |
Restore the most recent one.
| |
Restoring a specific point takes an option. I never tried it.
| |
Discarding local commits
To throw away commits that only exist locally and rewind to the remote, naming the target explicitly is the reliable form. This assumes develop is checked out.
| |
Without a target it seems to reset against the remote of whatever is checked out.
| |
rebase and merge
rebase and merge always confused me.
After losing work to rebase once, I stuck to merge only.
Looking it up: rebase means relocating the base of a branch.
Working in gitflow, I created a feature branch and then rebased the develop commits that had piled up in the meantime. The develop commits made during that work landed underneath the local feature branch.
The history stays clean, which is nice. There is one problem though. If the feature branch was already pushed, you end up with two feature branches. Since local is the newer one, deleting the feature on remote/origin and pushing fresh seems to fix it.
A diagram would explain this well, but I cannot draw.
During a rebase, conflicts are resolved one step at a time against each commit on the local feature branch. That can produce results you did not want — you may resolve the same file several times.
So if you are going to use rebase, keep the cycle short. The longer you wait, the more intermediate commits pile up and the more times you resolve.
Summary
- svn migration is
git svn clone --stdlayoutplus manual tag/branch cleanup - To discard local commits, name the target:
git reset --hard remotes/origin/<branch> - rebase relocates the base. Clean history, but a pushed branch splits into two
- Rebase often. Waiting means resolving the same file repeatedly