I’ve been working with the PKI/Dogtag code for a while. Over the past couple years, I’ve been more and more comfortable with Git. PKI uses SVN as a centralized Repository. Since Git SVN integration is fairly mature, I’ve been using that to manage my coding. On Monday, I gave a presentation to my team on Git SVN. I’ve taken the outline from the slides and included it here.
This presentation is available on the Dogtag website.
Why?
“Saved Gamesâ€
Craft Patches
Multitasking
Code Reviews
Lose nothing
Trust
No, really, why?
If I didn’t do this first, I’d spend the whole time in the next presentation explaining what I was doing
But we use Subversion!
SVN is a remote repository
Git for local revision control
Git can work with multiple remotes
To Git, Subversion is just another remote protocol
Is it going to change what I currently do?
Different set of commands, but they have a straightforward mapping to SVN
Different set of tools
Both have large communities with lots of wisdom.
This talk focuses on using git to augment your SVN interactions
How do I get started?
git svn clone \
http://svn.fedorahosted.org/svn/pki \
–prefix svn \
-T trunk -b branches -t tags
-T -b -t are svn specific
–stdlayout
–prefix lets us name the remote repo
You messed up!
My checkout was from:
svn+ssh://admiyo@svn.fedorahosted.org/svn
/pki/trunk/pki
Note the /pki at the end
My git commits won’t get accepted by the above repo
Push to SVN as “commit cleaning†method
Resort to patches if necessary
That is Slow! I SVN checkout all the time!
This got the entire history, all branches, all commits
You will do this only once!
Incremental changes are fetched
Git has a really good protocol for ensuring things stay in sync.
Why is there nothing inside the pki directory?
Nothing has been checked out from the local repository
List all branches: git branch -a
List all remote branches: git branch -r
Right now they are the same
To work with Trunk
$Â git checkout -b trunk svn/trunk
To work with PKI_8_BRANCH
git checkout -b svn/PKI_8_BRANCH PKI_8_BRANCH
To go back to trunk
git checkout trunk
What did that do?
man git checkout
-b creates a new branch
First unamed param is local branch name
Second unnamed param is the start point
Without -b and branch point, it uses a local branch
But I only work with one Branch at at time!
Git makes a local repository in .git/objects
Git branches are Cheap
Git branches are local
You can checkout branches from your local repository and FAST!
I need to make a change for the trunk.
git checkout -b branchname svn/trunk
Edit code
git add .
git commit -m “commit messageâ€
Uh Oh. I just messd up
git commit –amend
git reset HEAD~1
–soft : keeps your changes
–hard : clean slate
git reflog
I am not ready to commit it!
Commit goes to local repository
In git terms, you push to a remote repository
git svn dcommit
I need to create a patch for code review.
git format-patch -M -C –patience –full-index
I have scripted around this to use data out of the .git/config
Someone checked in changes. How do I merge?
What you want is rebase, not merge.
git svn fetch
git rebase svn/trunk
How would I do a code review?
Commit the changes for what you are working on
Create a branch off of master
Apply the patch to that branch
git am code_to_review.patch
git difftool HEAD~1 HEAD
I really don’t want to commit, but I don’t want to lose my changes
git stash.
Stack of changes, you can push and pop
When you pop, they will be applied to the current branch where-ever you are
How do I back up my work?
Git works with multiple repositories
Create an external git repo
git push
ssh://admiyo@fedorapeople.org/home/fedora/admiyo /public_git/pki.git
git push admiyo mywork:mywork
Could be done with Subversion as well
I looked in .git. What is that stuff?
Files are stored by a hash of their content
objects think hashtable
Refs: anything named
Tags: tags (Der!)
Remotes: Cached info about remote repositories
Heads:Â local branches
HEAD:Â what is currently checked out
Logs:Â just another series of Hashes
A branch is just the name of a a bunch of files
I can’t remember all this!
http://cheat.errtheblog.com/s/git
http://www.jukie.net/~bart/blog/svn-branches-in-git