Difference between revisions of "HowTo:Checkout GIT"

From VsWiki
Jump to: navigation, search
(Synchronize)
m (Set up: Make Boost v1.53 the preferred version)
 
(5 intermediate revisions by 3 users not shown)
Line 15: Line 15:
  
 
Normally git-svn will copy the full svn repository, that is all revisions of all files.
 
Normally git-svn will copy the full svn repository, that is all revisions of all files.
This takes takes a long time, and as you seldomly need the full history, you can instead copy from a given revision onwards.
+
This takes takes a long time, and as you seldom need the full history, you can instead copy from a given revision onwards.
  
 
This command will only copy the most recent revision. If you want the full history, remove the "-rHEAD" option:
 
This command will only copy the most recent revision. If you want the full history, remove the "-rHEAD" option:
 
<pre>
 
<pre>
git svn clone -rHEAD https://vegastrike.svn.sourceforge.net/svnroot/vegastrike/trunk/vegastrike/
+
git svn clone -rHEAD https://svn.code.sf.net/p/vegastrike/code/trunk/vegastrike/
 
</pre>
 
</pre>
  
 
Next you need to handle svn:externals. You can find them with "git svn show-externals". There may be a better way using git submodules, but this works.
 
Next you need to handle svn:externals. You can find them with "git svn show-externals". There may be a better way using git submodules, but this works.
 
<pre>
 
<pre>
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_28_0/boost/boost/ boost/1_28/boost
+
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_53_0/boost/ boost/1_53/boost
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_28_0/boost/libs/python/src/ boost/1_28/src
+
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_53_0/libs/python/src/ boost/1_53/src
 +
</pre>
 +
 
 +
For older versions of Boost:
 +
<pre>
 
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/boost/ boost/1_35/boost
 
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/boost/ boost/1_35/boost
 
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/libs/python/src/ boost/1_35/src
 
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/libs/python/src/ boost/1_35/src
 +
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_45_0/boost/ boost/1_45/boost
 +
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_45_0/libs/python/src/ boost/1_45/src
 
</pre>
 
</pre>
  
 
We recommend that you add the following lines to your .gitignore file, which should be created in the same directory as the .git directory is located.
 
We recommend that you add the following lines to your .gitignore file, which should be created in the same directory as the .git directory is located.
 
<pre>
 
<pre>
boost/1_28
+
boost/1_53
 +
boost/1_45
 
boost/1_35
 
boost/1_35
 
boost_patched_gcc44
 
boost_patched_gcc44
Line 38: Line 45:
 
You may also want to add auto-generated files to .gitignore.
 
You may also want to add auto-generated files to .gitignore.
  
Now you are almost ready to work on the codebase. You just need to create a branch to work on. This will make it easier to keep your local GIT repository synchonized with the remote SVN repository.
+
Now you are almost ready to work on the codebase. You just need to create a branch to work on. This will make it easier to keep your local GIT repository synchronized with the remote SVN repository.
  
 
  git branch ''insert-your-branch-name''
 
  git branch ''insert-your-branch-name''
Line 47: Line 54:
 
From here on, you can follow the normal build instructions.
 
From here on, you can follow the normal build instructions.
  
== Synchonize with SVN ==
+
== Synchronize with SVN ==
 
If others commit changes to the remote SVN repository, you can update your local GIT repository as follows.
 
If others commit changes to the remote SVN repository, you can update your local GIT repository as follows.
  
Line 61: Line 68:
 
  git checkout ''insert-your-branch-name''
 
  git checkout ''insert-your-branch-name''
 
  git pull . master
 
  git pull . master
 +
 +
== Submit your changes ==
 +
The "git commit" operation only commits your changes to your local GIT repository. When you want to submit your changes to the remote SVN repository, then you have two options.
 +
If you have commit privileges to the Vega Strike SVN repository, then you can use the "git svn dcommit" command. Otherwise you have to submit a patch to the Vega Strike forums.
 +
 +
You can either use
 +
 +
git diff --no-prefix master..''insert-your-branch-name'' > mypatch.diff
 +
 +
Better yet, you can use the following bash script, which will make sure that the output looks like an SVN patch.
 +
<pre>
 +
#!/bin/sh
 +
#
 +
# git-svn-diff
 +
# Generate an SVN-compatible diff against the tip of the tracking branch
 +
TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
 +
REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
 +
git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* |
 +
sed -e "s/^+++ .*/&    (working copy)/" -e "s/^--- .*/&    (revision $REV)/" \
 +
-e "s/^diff --git [^[:space:]]*/Index:/" \
 +
-e "s/^index.*/===================================================================/"
 +
</pre>
 +
For a more complete script see [https://gist.github.com/710219 git-svn-diff.sh].

Latest revision as of 11:28, 18 February 2017

This page describes how to use GIT with the Vega Strike SVN repository.

GIT is a distributed sourcecode revision control system, which allows you to commit changes to a local repository and from there commit the changes to the remove Vega Strike SVN repository. This is useful if you want to experiment with the codebase, or if you do not have commit privileges to the Vega Strike SVN repository.

If you are unfamiliar with GIT, the you should start by reading the GIT SVN Crash Course.

Installation

First you need to install the GIT and GIT-SVN packages. How you do this, depends on your system.

See the chapter 2 in the GIT Book.

Set up

After installing the two packages above, you have to set up a local git repository for the Vega Strike codebase.

Normally git-svn will copy the full svn repository, that is all revisions of all files. This takes takes a long time, and as you seldom need the full history, you can instead copy from a given revision onwards.

This command will only copy the most recent revision. If you want the full history, remove the "-rHEAD" option:

git svn clone -rHEAD https://svn.code.sf.net/p/vegastrike/code/trunk/vegastrike/

Next you need to handle svn:externals. You can find them with "git svn show-externals". There may be a better way using git submodules, but this works.

git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_53_0/boost/ boost/1_53/boost
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_53_0/libs/python/src/ boost/1_53/src

For older versions of Boost:

git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/boost/ boost/1_35/boost
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_35_0/libs/python/src/ boost/1_35/src
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_45_0/boost/ boost/1_45/boost
git svn clone -rHEAD http://svn.boost.org/svn/boost/tags/release/Boost_1_45_0/libs/python/src/ boost/1_45/src

We recommend that you add the following lines to your .gitignore file, which should be created in the same directory as the .git directory is located.

boost/1_53
boost/1_45
boost/1_35
boost_patched_gcc44

You may also want to add auto-generated files to .gitignore.

Now you are almost ready to work on the codebase. You just need to create a branch to work on. This will make it easier to keep your local GIT repository synchronized with the remote SVN repository.

git branch insert-your-branch-name
git checkout insert-your-branch-name

Replace insert-your-branch-name with the name that you want to call your branch.

From here on, you can follow the normal build instructions.

Synchronize with SVN

If others commit changes to the remote SVN repository, you can update your local GIT repository as follows.

Make sure that you have committed all your changes to the local GIT repository before you start synchronizing.

First you need to update the trunk of your local GIT repository with the changes from the remote SVN repository.

git checkout master
git svn rebase

Next you can synchronize your branch with the trunk.

git checkout insert-your-branch-name
git pull . master

Submit your changes

The "git commit" operation only commits your changes to your local GIT repository. When you want to submit your changes to the remote SVN repository, then you have two options. If you have commit privileges to the Vega Strike SVN repository, then you can use the "git svn dcommit" command. Otherwise you have to submit a patch to the Vega Strike forums.

You can either use

git diff --no-prefix master..insert-your-branch-name > mypatch.diff

Better yet, you can use the following bash script, which will make sure that the output looks like an SVN patch.

#!/bin/sh
#
# git-svn-diff
# Generate an SVN-compatible diff against the tip of the tracking branch
TRACKING_BRANCH=`git config --get svn-remote.svn.fetch | sed -e 's/.*:refs\/remotes\///'`
REV=`git svn find-rev $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH)`
git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* |
sed -e "s/^+++ .*/&    (working copy)/" -e "s/^--- .*/&    (revision $REV)/" \
-e "s/^diff --git [^[:space:]]*/Index:/" \
-e "s/^index.*/===================================================================/"

For a more complete script see git-svn-diff.sh.