Difference between revisions of "Git"

From Gramps
Jump to: navigation, search
(Workflow)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
A guide for people who would like to use [http://git-scm.com/ Git] rather than subversion (SVN).
+
#REDIRECT [[Brief_introduction_to_Git]]
 
 
[[User:Jralls|John Ralls]] has provided a Git mirror of the Gramps subversion repository which is updated every day.
 
 
 
== Installation ==
 
 
 
First install git and the git-svn bridge.  In Ubuntu use the following command:
 
 
 
sudo apt-get install git git-svn
 
 
 
''Note'': The git package is called git-core in older distributions.
 
 
 
Next download a local copy of Gramps from the mirror provided by John Ralls.  This will take about 5 minutes.
 
 
 
git clone -o mirror <nowiki>https://github.com/jralls/Gramps</nowiki>
 
 
 
Finally initialise the remote svn connection from the local copy directory. Replacing <USERNAME> with your SourceForge username.
 
 
 
cd Gramps
 
git svn init --prefix=mirror/ -s svn+ssh://<USERNAME>@svn.code.sf.net/p/gramps/code
 
 
 
If you plan working with branches other than the trunk, adjust the configuration to allow for the hierarchical branch namespace structure of Gramps. In the ~/Gramps/.git/config file,
 
in the section
 
 
 
[svn-remote "svn"]
 
 
 
add these lines along with the existing branches line that was written there by the git svn init command:
 
 
 
branches = branches/maintenance/*:refs/remotes/mirror/maintenance/*
 
branches = branches/geps/*:refs/remotes/mirror/geps/*
 
 
 
== Workflow ==
 
 
 
By default a branch called trunk is created for you.  To update a branch with the latest changes in the git mirror use:
 
 
 
git pull --rebase
 
 
 
When committing changes to the subversion repository we need a linear history, so we specify the --rebase option.
 
 
 
To commit changes back to the subversion repository use:
 
 
 
git svn dcommit
 
 
 
'''Caution''': Do not attempt to push changes back to the git mirror.
 
 
 
Note that the upstream git repository doesn't instantly get in sync from the SVN, so after you perform the dcommit operation
 
you might see something like
 
 
 
Your branch is ahead of 'mirror/trunk' by 2 commits
 
 
 
If, after that, you try to do a dcommit and it complains about being out of sync, don't try to do a "git pull --rebase", or you'll rewind your index back to the last git update point! You can try to fix it instead with
 
git svn fetch -p
 
git svn rebase
 
and then dcommit again.
 
 
 
If that doesn't help, try using git svn reset to an earlier version and doing git svn fetch -p from it, then git svn reset to the svn revision at the mirror/trunk current position.
 
 
 
=== hacking svn properties ===
 
According to [[committing policies]], any new files you add require settings of svn properties. See [[Committing_policies#HOWTO_setting_the_properties_with_git-svn]] for the details.
 
 
 
== Branches ==
 
 
 
To see the remote branches available in the mirror use:
 
 
 
git remote show mirror
 
 
 
Before switching to another branch it is useful to remove untracked files created by the build process.  You can do this with the following command:
 
 
 
git clean -dxf
 
 
 
To create a new local tracking branch use the checkout command.  For example, to create a branch that tracks the gramps34 maintenance branch use:
 
 
 
git checkout -b gramps34 mirror/maintenance/gramps34
 
 
 
Then fetch the corresponding branch svn rev history with
 
 
 
git svn fetch -p
 
 
 
(This can also be done at a later stage, as long as you have switched to the branch with "git checkout gramps34".)
 
 
 
The branch command allows you to see all the local branches and indicates which branch is active.
 
 
 
git branch
 
 
 
To switch to a branch use the checkout command.  For example, to switch to trunk use:
 
 
 
git checkout trunk
 
 
 
== References ==
 
 
 
* http://git-scm.com/book
 
* http://wiki.gnucash.org/wiki/Git
 
* http://www.kernel.org/pub/software/scm/git/docs/git-svn.html
 
* http://www.tfnico.com/presentations/git-and-subversion
 
* http://blog.tfnico.com/2011/09/git-svn-mirror-without-annoying-update.html
 
 
 
==See also==
 
* [[Getting_started_with_Gramps_development#Get_the_source_tree|Getting started with Gramps development - Get the source tree]]
 
 
 
[[Category:Developers/General]]
 

Latest revision as of 00:15, 20 January 2020