Git usage: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Ceros
m (→‎Other Repos: new location for git repo in github)
>Theuni
No edit summary
Line 1: Line 1:
There's now a git repository available for XBMC. This page is intended as an instructional page showing how to clone the XBMC git repository along with notes on how to start fetching newer revisions through XBMC's svn repository.
XBMC now uses git for as its main scm. The main repo is located at [https://github.com/xbmc/xbmc github]
 
Eventually, the git repository will be the main repository for development. Currently, the git repository is synced with changes made to the svn repository every four minutes.


First thing, clone the repo.
First thing, clone the repo.
<source lang="bash">
<source lang="bash">
   $ git clone git://xbmc.git.sourceforge.net/gitroot/xbmc/xbmc
   $ git clone git@github.com:xbmc/xbmc.git
</source>
</source>


After cloning the repo, you may notice a lot of branches that are no longer in the svn repo, and also branches and tags which are appended with '@' followed by some number. These are all the branches and tags git-svn found when doing the initial import from the svn repo. If you do not intend to track svn, you may proceed to delete these stale branches, otherwise, you should keep them so that the time to do an initial fetch with git-svn doesn't take days (that's right, DAYS).
== Fetch old branches and extra history ==
'''The following is ONLY useful for developers who wish to see extended XBMC history. Everyone else should stop here.'''
Run this command from your tree. It requires git 1.6.5 or higher:
<source lang="bash">
$ git fetch origin refs/old/heads/*:refs/remotes/svn-migration/* refs/replace/*:refs/replace/*
</source>


== Other Repos ==
== Platform Settings ==
There are also other repos that are kept in sync with new changes from the svn repository.
 
A repository is available at github.
  git://github.com/xbmc/xbmc.git
 
== Git (OSX/Windows) ==
=== Case Insensitive File Systems===
=== Case Insensitive File Systems===
Git wants to run under a case sensitive file system but under OSX and Windows, the file system might be case insensitive. Make sure that core.ignorecase is properly set. Check with:
Git wants to run under a case sensitive file system but under OSX and Windows, the file system might be case insensitive. Make sure that core.ignorecase is properly set. Check with:
Line 23: Line 20:
<source lang="bash">$ git-config --global core.ignorecase true</source>
<source lang="bash">$ git-config --global core.ignorecase true</source>


== Sync with SVN For dcommit ==
=== Line Endings===
'''The following is ONLY useful if you have svn commit access. Everyone else should stop here.'''
 
<source lang="bash">
Windows users MUST use the git autocrlf feature. This is set by default by tortoise. If it's not set, you can do so manually:
$ cd xbmc
<source lang="bash">$ git config --global core.autocrlf true</source>
$ git svn init --stdlayout --prefix=origin/ https://xbmc.svn.sourceforge.net/svnroot/xbmc
$ git config svn-remote.svn.tags tags/*:refs/tags/*
</source>
NOTE: Don't forget the trailing '/' for the prefix option in 'git svn init'.


Now do the fetch. If you left all branches and tags that were cloned alone, this should take roughly half an hour, as opposed to several days.
Linux and OSX users should set autocrlf to 'input'
<source lang="bash">
<source lang="bash">$ git config --global core.autocrlf input</source>
$ git svn fetch
</source>
It is possible to fetch history only from a certain SVN revision (1234 in this example) with the following:
<source lang="bash">
$ git svn fetch -r 1234
</source>


You will save yourself a headache by removing the git url so that you can't fetch it by accident:
== Updating ==
<source lang="bash">
$ git config --unset remote.origin.url
</source>


When updating from the main git repo (by default git will call this 'origin'), you should always rebase on top of your history, unless you know what you're doing.


Once finished, you should be at the master branch which tracks 'trunk' from svn. You can check by doing a dry-run of a check in to svn, via the dcommit command from git-svn.
=== Linux/OSX ===
<source lang="bash">
Always use <source lang="bash">git pull --rebase</source>
$ git svn rebase
$ git svn dcommit -n
Committing to https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk ...
</source>
NOTE: Don't forget the '-n' option to perform a dry-run, otherwise it will try to perform an actual check in.


That's basically all there is to it. To keep following svn for new revisions, it's simply fetching new changes again and rebasing.
A safe bet is to set this to be done automatically.
<source lang="bash">
<source lang="bash">$ git config branch.master.rebase true</source>
$ git svn fetch && git svn rebase
== Pushing ==
</source>
Please use <source lang="bash">git log</source> to look at the log before committing. If there are merge commits that you don't understand, please ask for help before pushing.
'''Never EVER force a push (non-fast-forward commit) to mainline. Ever. Doing so will result in your push privileges being revoked.

Revision as of 18:59, 4 January 2011

XBMC now uses git for as its main scm. The main repo is located at github

First thing, clone the repo.

  $ git clone [email protected]:xbmc/xbmc.git

Fetch old branches and extra history

The following is ONLY useful for developers who wish to see extended XBMC history. Everyone else should stop here. Run this command from your tree. It requires git 1.6.5 or higher:

$ git fetch origin refs/old/heads/*:refs/remotes/svn-migration/* refs/replace/*:refs/replace/*

Platform Settings

Case Insensitive File Systems

Git wants to run under a case sensitive file system but under OSX and Windows, the file system might be case insensitive. Make sure that core.ignorecase is properly set. Check with:

$ git-config --list

if not set:

$ git-config --global core.ignorecase true

Line Endings

Windows users MUST use the git autocrlf feature. This is set by default by tortoise. If it's not set, you can do so manually:

$ git config --global core.autocrlf true

Linux and OSX users should set autocrlf to 'input'

$ git config --global core.autocrlf input

Updating

When updating from the main git repo (by default git will call this 'origin'), you should always rebase on top of your history, unless you know what you're doing.

Linux/OSX

Always use

git pull --rebase

A safe bet is to set this to be done automatically.

$ git config branch.master.rebase true

Pushing

Please use

git log

to look at the log before committing. If there are merge commits that you don't understand, please ask for help before pushing.

Never EVER force a push (non-fast-forward commit) to mainline. Ever. Doing so will result in your push privileges being revoked.