FlightGear Git: Difference between revisions

Jump to navigation Jump to search
Cleanup
(review complete)
(Cleanup)
Line 1: Line 1:
'''Git''' is a version control system used by the [[FlightGear]] project to store all of the files required to build the FlightGear, including all the programs, the data (e.g. [[aircraft]]), supporting tools, etc. Git tracks updates to every file as developers around the world work together concurrently to create new versions.  
{{FlightGearGitOn}}
 
'''Git''' is a version control system used by the [[FlightGear]] project to store all of the files required to build the FlightGear, including all the programs, the data (e.g. [[aircraft]]), supporting tools, etc. Git tracks updates to every file, as developers from around the world work together concurrently to create new versions.


While new FlightGear features and additions are in development, they are available from Git before they are available in the standard release version. Using Git allows users to build the newest possible version of FlightGear from the latest source files, to experiment with new aircraft or other features. However, it's not a beginner's tool. Using Git can expose the user to unstable features that show ugly error messages, or crash the computer.  
While new FlightGear features and additions are in development, they are available from Git before they are available in the standard release version. Using Git allows users to build the newest possible version of FlightGear from the latest source files, to experiment with new aircraft or other features. However, it's not a beginner's tool. Using Git can expose the user to unstable features that show ugly error messages, or crash the computer.  
Line 9: Line 11:
* [[FlightGear Git on Windows]]
* [[FlightGear Git on Windows]]
* [[Howto:Start using git]] provides a quick introduction to using a "source code management system"
* [[Howto:Start using git]] provides a quick introduction to using a "source code management system"
<br />


== '''Motivation''' ==
== Motivation ==
Much has been written on the advantages of Git over CVS. For the FlightGear project, some advantages are:
Much has been written on the advantages of Git over CVS. For the FlightGear project, some advantages are:
* Much better support for branches and merging branches. This is especially important for creating bug-fix releases for major releases while still allowing work on the next major release to continue. It is also very nice for a developer's personal work-flow.
* Much better support for branches and merging branches. This is especially important for creating bug-fix releases for major releases while still allowing work on the next major release to continue. It is also very nice for a developer's personal work-flow.
Line 19: Line 20:
Also, as noted before, the CVS servers had a hardware failure on May 2010, speeding up FlightGear's change to Git.
Also, as noted before, the CVS servers had a hardware failure on May 2010, speeding up FlightGear's change to Git.


 
== Manipulating the GIT ==
== '''Manipulating the GIT''' ==
=== Work-flow Overview===
=== Work-flow Overview===
{|
{|
||[[File:GIT-Workflow.png]]
||[[File:GIT-Workflow.png]]
|}
|}
For a detailed description see the description of the 4 repositories (A,B,C,D) in the following chapters
For a detailed description see the description of the four repositories (A,B,C,D) in the following chapters.
<br /><br />
 
=== A) Repositories and branches ===
=== A) Repositories and branches ===
For historical reasons there continue to be separate repositories for [https://gitorious.org/fg/simgear '''''SimGear'''''] and [https://gitorious.org/fg/flightgear '''''FlightGear''''']. For most users and developers the most interesting ones for those 2 are:
For historical reasons there continue to be separate repositories for [https://gitorious.org/fg/simgear '''''SimGear'''''] and [https://gitorious.org/fg/flightgear '''''FlightGear''''']. For most users and developers the most interesting ones for those 2 are:
* '''''next''''': The current tip of new development. This branch should always compile and run, but various things could be broken.
* '''''next''''': The current tip of new development. This branch should always compile and run, but various things could be broken.
* '''''release/*''''': The branch subdirectory containing former and ''(if there is already defined one)'' upcoming releases.
* '''''release/*''''': The branch subdirectory containing former and ''(if there is already defined one)'' upcoming releases.
For all available branches see https://gitorious.org/fg/simgear/trees and/or https://gitorious.org/fg/flightgear/trees
For all available branches, see [https://gitorious.org/fg/simgear/trees SimGear branches] and/or [https://gitorious.org/fg/flightgear/trees FlightGear branches]
<br /><br />
 
FlightGear [https://gitorious.org/fg/fgdata '''''data''''''s] branches of interest are:
FlightGear [https://gitorious.org/fg/fgdata '''''data''''''] branches of interest are:
* '''''master''''': The one that is used with the '''''next''''' branch of the code.
* '''''master''''': The one that is used with the '''''next''''' branch of the code.
* '''''release/*''''': The one that is used with the '''''release''''' branch of the code.
* '''''release/*''''': The one that is used with the '''''release''''' branch of the code.
For all available branches see https://gitorious.org/fg/fgdata/trees
For all available branches see https://gitorious.org/fg/fgdata/trees
<br /><br />
 
For other available projects have a look at our [http://gitorious.org/fg gitorious.org]. Use the "Source tree" button to see all available branches unique to those projects.
For other available projects have a look at our [http://gitorious.org/fg gitorious.org]. Use the "Source tree" button to see all available branches unique to those projects.
<br /><br />
 
'''''Warning:'''''  
'''''Warning:'''''  
*The "fgdata" project will be used in all following examples - thus the "Prime" local repository will always be named "master"!  
* The "fgdata" project will be used in all following examples - thus the "Prime" local repository will always be named "master"!  
*If you do test changes, make sure all branches have the same status - otherwise your setup may not be functional!
* If you test changes, make sure all branches have the same status - otherwise your setup may not be functional!
<br /><br />
 
=== B) Create your own workspace on Gitorious ===
=== B) Create your own workspace on Gitorious ===
Prior to be able to manipulate GIT-data you must be a registered User and be logged in as such. See
Prior to be able to manipulate GIT-data you must be a registered user and be logged in as such. See
: https://gitorious.org/users/new  
: https://gitorious.org/users/new  
: https://gitorious.org/login
: https://gitorious.org/login
Line 55: Line 55:
* getstart
* getstart
* etc.
* etc.
Create your own "GIT-Clone" ''(as a space to work in)'' by activating the "Clone repository" button of the wanted project. By default you will be cloning the '''''next''''' or '''''master''''' branch of that project --> that is the actual repository including the newest, not yet formally distributed, changes. That is probably what you want if you want to  
 
Create your own "GIT-Clone" ''(as a space to work in)'', by activating the "Clone repository" button of the wanted project. By default you will be cloning the '''''next''''' or '''''master''''' branch of that project --> that is the actual repository including the newest, not yet formally distributed, changes. That is probably what you want if you want to  
* assist with reporting bugs before they are released as a proper release version
* assist with reporting bugs before they are released as a proper release version
* or participate in the design
* or participate in the design
Line 62: Line 63:
The created GIT-clone will be on you private page '''https://gitorious.org/~<small>YourUID</small>'''
The created GIT-clone will be on you private page '''https://gitorious.org/~<small>YourUID</small>'''
<small>''("YourUID" being your ID you logged in with, and do not forget the "~" in front of it!)''</small>)
<small>''("YourUID" being your ID you logged in with, and do not forget the "~" in front of it!)''</small>)
<br /><br />
 
=== C) Create a "master" on your local PC ===
=== C) Create a "master" on your local computer ===
''All the following is shown as performed in an UBUNTU "Terminal" environment! Please adapt especially the directory trees according to your Operating-System!''
''All the following is shown as performed in an UBUNTU "Terminal" environment! Please adapt especially the directory trees according to your Operating-System!''
# Create a unique folder on your PC, e.g. "..'''\GIT'''"
# Create a unique folder on your computer, e.g. "..'''\GIT'''"
# change into that folder and use the following "git clone" commands to clone the wanted repository
# Change into that folder and use the following "git clone" commands to clone the wanted repository
#* ''if you need/want more informations about unique GIT-commands, input "git help [command]"'' <small>(e.g. "git help clone")</small>
#* ''if you need/want more informations about unique GIT-commands, input "git help [command]"'' <small>(e.g. "git help clone")</small>
# use one of the following commands (or similar) from within that "..'''\GIT'''"-folder:
# Use one of the following commands (or similar) from within that "..'''\GIT'''"-folder:
:*for cloning '''''SimGear''''' use:
:*for cloning '''''SimGear''''' use:
::'''<nowiki>git clone git://gitorious.org/fg/simgear.git</nowiki>''' [target]
::'''<nowiki>git clone git://gitorious.org/fg/simgear.git</nowiki>''' [target]
Line 83: Line 84:


'''<code>cd</code>''' into the new folder [target]
'''<code>cd</code>''' into the new folder [target]
:You are now inside the ''working tree'' of this git repository. The repository itself is stored inside the subfolder <tt>../GIT/[target]/.git</tt>, which we mustn't edit manually. Git will take care of that.
:You are now inside the ''working tree'' of this git repository. The repository itself is stored inside the subfolder <tt>../GIT/[target]/.git</tt>, which we must not edit manually. Git will take care of that.
:<small>Notice the "'''.'''" in front of the name: In Linux that indicates a hidden file, for which you might have to enable "show hidden files"!</small>
:<small>Notice the "'''.'''" in front of the name: In Linux that indicates a hidden file, for which you might have to enable "show hidden files"!</small>


;<code>git branch</code>
;<code>git branch</code>
: will show the active [[FlightGear_and_Git#A.29_Repositories_and_branches|branches]].  e.g.
: will show the active [[FlightGear_and_Git#A.29_Repositories_and_branches|branches]].  e.g.
<small>
  ..GIT/fgdata$ '''git branch'''
  ..GIT/fgdata$ '''git branch'''
  * master
  * master
  master.local  <small>''(<-- this branch will not be there initially!)''</small>
  master.local  <small>''(<-- this branch will not be there initially!)''</small>
:</small>Right after download the active GIT-repository-branch will be <tt>'''"next"'''</tt>, which in the example is called "master". The "'''*'''" in front means that this is now the active one! i.e. the content of the active ''working tree'' is the bleeding edge of the source code.
:Right after download the active GIT-repository-branch will be <tt>'''"next"'''</tt>, which in the example is called "master". The "'''*'''" in front means that this is now the active one! i.e. the content of the active ''working tree'' is the bleeding edge of the source code.


;<code>git branch -a</code>
;<code>git branch -a</code>
: will list '''''all''''' branches of a git repository. The one marked with an asterisk (*) is the active one. e.g.:
: will list '''''all''''' branches of a git repository. The one marked with an asterisk (*) is the active one. e.g.:
<small>
  ..GIT/fgdata$ '''git branch -a'''
  ..GIT/fgdata$ '''git branch -a'''
  * master
  * master
Line 108: Line 107:
   remotes/origin/release/2.6.0
   remotes/origin/release/2.6.0
   remotes/origin/releases/2.2.0
   remotes/origin/releases/2.2.0
</small>


You now have your local "GIT-master".
You now have your local "GIT-master".
'''But:''' To make individual changes ''(like editing a joystick file)'' add a plane to fgdata or patch the source code. It is always recommended to create a local branch inside that "master" repository. In the chapter "[[FlightGear_and_Git#Edit|Edit]]" we will describe a way to achieve this. But have in mind, that this is very basic and only suits for users who have minor changes.  
'''But:''' To make individual changes ''(like editing a joystick file)'', add a plane to fgdata or patch the source code. It is always recommended to create a local branch inside that "master" repository. In the chapter "[[FlightGear and Git#Edit|Edit]]" we will describe a way to achieve this. But have in mind, that this is very basic and only suits for users who have minor changes.  
<br /><br />
 
==== Special for '''fgdata''':====
==== Special for '''fgdata''':====
At the time of writing the data repository is about ''3.4 GB''. Continuing an interrupted cloning of a repository is '''not supported''' within git. Therefore, if you have a slow or unstable connection to the internet, it is recommended to download the [[FlightGear and Git#fgdata.bundle|fgdata.bundle]].
At the time of writing the data repository is about ''3.4 GB''. Continuing an interrupted cloning of a repository is '''not supported''' within git. Therefore, if you have a slow or unstable connection to the internet, it is recommended to download the [[FlightGear and Git#fgdata.bundle|fgdata.bundle]].
Line 133: Line 131:


Do the following steps to extract the bundle and bring the repository up to date:
Do the following steps to extract the bundle and bring the repository up to date:
<small>
  $ git '''clone fgdata.bundle fgdata'''
  $ git '''clone fgdata.bundle fgdata'''
  $ cd fgdata
  $ cd fgdata
Line 144: Line 141:
  $ git checkout master
  $ git checkout master
  $ git branch -D master-tmp
  $ git branch -D master-tmp
</small>


If you get an error at '''<code>git fetch origin</code>''' try:
If you get an error at '''<code>git fetch origin</code>''' try:
<small>
  $ git remote rm origin
  $ git remote rm origin
  $ git remote add origin git://mapserver.flightgear.org/fgdata/
  $ git remote add origin git://mapserver.flightgear.org/fgdata/
  $ git fetch origin
  $ git fetch origin
</small>
 
You should be suspicious if based on the printed progress you estimate the data download during the fetch will exceed 1GB (assuming the bundle is not terribly outdated).
You should be suspicious if based on the printed progress you estimate the data download during the fetch will exceed 1GB (assuming the bundle is not terribly outdated).
<br /><br />
 
=== D) Edit and Commit Data ===
=== D) Edit and commit data ===
====Edit====
====Edit====
Switch into the branch in which you want to edit your changes ''(without affecting your master yet!)''. We will use for that branch the name "master.local". Thus:
Switch into the branch in which you want to edit your changes ''(without affecting your master yet!)''. We will use for that branch the name "master.local". Thus:
;<code>git checkout master</code>
;<code>git checkout master</code>
<small>
  ..GIT/fgdata$ '''git checkout master'''
  ..GIT/fgdata$ '''git checkout master'''
  Switched to branch 'master'
  Switched to branch 'master'
</small>
:will change the active [[FlightGear and Git#Repositories and Branches|branch]] to <tt>master</tt>. Means, that the content of the ''working tree'' will be changed to that state.
:will change the active [[FlightGear and Git#Repositories and Branches|branch]] to <tt>master</tt>. Means, that the content of the ''working tree'' will be changed to that state.
:In case you get an error like
:In case you get an error like
<small>
  GIT/fgdata$ '''git checkout master'''
  GIT/fgdata$ '''git checkout master'''
  Already on 'master'
  Already on 'master'
  Your branch is ahead of 'origin/master' by 2 commits.
  Your branch is ahead of 'origin/master' by 2 commits.
</small>
:you should re-sync your master with e.g.:
:you should re-sync your master with e.g.:
:;<code>git fetch</code>
:;<code>git fetch</code>
<br />
 
;<code>git checkout -b master.local master</code>
;<code>git checkout -b master.local master</code>
<small>
  ..GIT/fgdata$ '''git checkout -b master.local master'''
  ..GIT/fgdata$ '''git checkout -b master.local master'''
  Switched to a new branch 'master.local'
  Switched to a new branch 'master.local'
</small>
:Generates the new "master.local" and switches to it.
:Generates the new "master.local" and switches to it.
:In case you get the response  
:In case you get the response:
<small>
  fatal: A branch named 'master.local' already exists.
  fatal: A branch named 'master.local' already exists.
</small>
::*you have to define another name for that branch
::*you have to define another name for that branch
::*or delete it:
::*or delete it:
Line 191: Line 178:
*start FlightGear to verify they are proper/functional
*start FlightGear to verify they are proper/functional
*then check what was done:'''''
*then check what was done:'''''
</span><br />
</span>
 
;<code>git status</code>
;<code>git status</code>
:<small>the output may take some time to appear!</small>
:<small>the output may take some time to appear!</small>
:see e.g. a dummy-example:
:see e.g. a dummy-example:
<small>
  ..GIT/fgdata$ '''git status'''
  ..GIT/fgdata$ '''git status'''
  # On branch master.local
  # On branch master.local
Line 211: Line 198:
  no changes added to commit (use "git add" and/or "git commit -a")
  no changes added to commit (use "git add" and/or "git commit -a")
  ...... etc.
  ...... etc.
</small>
:This gives you a list of files that have been altered or that are new. In the above ''(dummy example)'' you see:
:This gives you a list of files that have been altered or that are new. In the above ''(dummy example)'' you see:
:*the already existing file "Aircraft/ATC-ML/Version" was modified
:*the already existing file "Aircraft/ATC-ML/Version" was modified
:*a new file "Aircraft/ATC-ML/Version (copy)" was added
:*a new file "Aircraft/ATC-ML/Version (copy)" was added
:*and a new directory "Aircraft/DUMMY/" was added, including all its files  
:*and a new directory "Aircraft/DUMMY/" was added, including all its files  
<br />
 
If that is what you wanted/needed continue with the following ''(otherwise correct your work first)''
If that is what you wanted/needed continue with the following ''(otherwise correct your work first)''
<br /><br />
 
'''''So we want to "add" those changes:'''''
'''''So we want to "add" those changes:'''''
;<code>git add "Aircraft/ATC-ML/Version (copy)"</code>
;<code>git add "Aircraft/ATC-ML/Version (copy)"</code>
Line 224: Line 210:
;<code>git add Aircraft/DUMMY/</code>
;<code>git add Aircraft/DUMMY/</code>
If you now perform the '''git status''' again you should see something similar to:
If you now perform the '''git status''' again you should see something similar to:
<small>
  ../GIT/fgdata$ ''git status''
  ../GIT/fgdata$ ''git status''
  # On branch master.local
  # On branch master.local
Line 238: Line 223:
   ''... etc.''
   ''... etc.''
  #
  #
</small>
If that is all you need - you may "commit" it:
If that is all you need - you may "commit" it:
<br /><br />
 
===="Commit"====
===="Commit"====
;<code>git commit -m "''your short, accompanying Announcement''"</code>
;<code>git commit -m "''your short, accompanying Announcement''"</code>
Line 246: Line 230:


;<code>git log</code>
;<code>git log</code>
<small>
  ..GIT/fgdata$ git log
  ..GIT/fgdata$ git log
  commit 7658c67c16a79900acf99dbfd85499b720dcc920
  commit 7658c67c16a79900acf99dbfd85499b720dcc920
Line 253: Line 236:
    
    
     your short, accompanying Announcement
     your short, accompanying Announcement
</small>
: This is the "commit" as it will be tracked within the GIT.
: This is the "commit" as it will be tracked within the GIT.
: You definitely should now copy the ID ''(the first 8 digits may be enough)'' to use it later as a unique identifier!
: You definitely should now copy the ID ''(the first 8 digits may be enough)'' to use it later as a unique identifier!


<br />
Now return to your local "master" with:
Now return to your local "master" with:
;<code>git checkout master</code>
;<code>git checkout master</code>
Line 271: Line 252:
;<code>git rebase origin/master</code>
;<code>git rebase origin/master</code>
:finally update the "master" with the "commit" on top of it
:finally update the "master" with the "commit" on top of it
<br />
 
=== Push your changes to your clone on Gitorious ===
=== Push your changes to your clone on Gitorious ===
;<code>git push git@gitorious.org:~<small>YourUID</small>/fg/<small>YourUID</small>s-fgdata.git</code>
;<code>git push git@gitorious.org:~<small>YourUID</small>/fg/<small>YourUID</small>s-fgdata.git</code>
Line 283: Line 264:
*Open your git-clone on Gitorious: https://gitorious.org/~<small>YourUID</small>/fg/<small>YourUID</small>-fgdata
*Open your git-clone on Gitorious: https://gitorious.org/~<small>YourUID</small>/fg/<small>YourUID</small>-fgdata
*and click the "Request merge" button on the right:
*and click the "Request merge" button on the right:
<br />
 
{|
[[File:Create merge request at Gitorious.png|thumb|270px|Creating a merge request at Gitorious.]]
||[[File:Create merge request at Gitorious.png|left|thumb|270px|Creating a merge request at Gitorious.]]||
Write a short summary, in which you explain what your commit(s) do(es). Then choose the following settings:
Write a short summary in which you explain what your commit(s) do. Then choose the following settings:
: '''Target directory:''' fgdata, flightgear or simgear
: '''Target directory:''' fgdata or FlightGear or SimGear
: '''Target branch:''' master, next or whatever
: '''Target branch:''' master or next or whatever
: '''Source branch:''' master, next or whatever
: '''Source branch:''' master or next or whatever
Next select the commits you would like to include in your merge request and click "Create merge request".
Next select the commits you'd like to include in your merge request and click "Create merge request".
 
|}
=== Commit the changes into the GIT ===
=== '''Commit the changes into the GIT''' ===
<span style="color:red">'''''This step is for developers with fgdata commit access only!'''''</span>
<span style="color:red">'''''This step is for developers with fgdata commit access only!'''''</span>
<br />
 
For a list of those authorized see: https://gitorious.org/+flightgear-developers/memberships  
For a list of those authorized see: https://gitorious.org/+flightgear-developers/memberships  
<br />
 
To push a merge request to fgdata, the following work-flow can be followed:
To push a merge request to fgdata, the following work-flow can be followed:
{{pre2|scroll|
  git checkout -b integration # the integration branch should not yet exist. You can use any name you'd like
  git checkout -b integration # the integration branch should not yet exist. You can use any name you'd like
  git pull git://gitorious.org/fg/fgdata.git refs/merge-requests/1 # make sure you change 1 to the id of the merge request
  git pull git://gitorious.org/fg/fgdata.git refs/merge-requests/1 # make sure you change 1 to the id of the merge request
  git rebase master # place the new commits on top of existing commits (without ugly "Merge branch into ...")
  git rebase master # place the new commits on top of existing commits (without ugly "Merge branch into ...")
  git checkout master
  git checkout master
  git cherry-pick b049e1d # repeat this for each commit you'd like to push
  git cherry-pick b049e1d # repeat this for each commit you'd like to push
  git push
  git push}}
<br /><br />
 
----
== Supporting information ==
== '''Supporting Informations''' ==
=== Some more helpful commands ===
=== Some more helpful commands ===
;<code>git help</code>
;<code>git help</code>
Line 316: Line 296:
;<code>git pull</code>'''
;<code>git pull</code>'''
: may be used for future updates
: may be used for future updates
<br />
 
=== Tracking a release branch ===
=== Tracking a release branch ===
<pre>
git branch -t -l release/2.6.0 origin/release/2.6.0
git branch -t -l release/2.6.0 origin/release/2.6.0
git checkout -b release/2.6.0
git checkout -b release/2.6.0
 
</pre>
=== Git tutorials and resources ===
=== Git tutorials and resources ===
* Git [http://git-scm.com/documentation documentation and tutorials]
* Git [http://git-scm.com/documentation documentation and tutorials]
Line 331: Line 310:
* [http://sourceforge.net/projects/qgit qgit - interactive git repository viewer and frontend]
* [http://sourceforge.net/projects/qgit qgit - interactive git repository viewer and frontend]
* Additional [[Resources WRT running git on Win32]]
* Additional [[Resources WRT running git on Win32]]
== Related content ==
* [[FlightGear Git: splitting fgdata]], an initiative to split the aircraft out of the fgdata repository, in order to decrease its size and thus improve access to the average user/developer.


{{Building}}
{{Building}}
Line 336: Line 318:
[[Category:Core developer documentation]]
[[Category:Core developer documentation]]
[[Category:FlightGear]]
[[Category:FlightGear]]
[[fr:FlightGear et Git]]
[[fr:FlightGear et Git]]

Navigation menu