Howto:Start using git: Difference between revisions

Jump to navigation Jump to search
m
Copyediting; headings
No edit summary
m (Copyediting; headings)
Line 4: Line 4:
See [http://code.google.com/p/tortoisegit/ TortoiseGit] for a Windows specific GUI.
See [http://code.google.com/p/tortoisegit/ TortoiseGit] for a Windows specific GUI.


== A handful of useful commands ==
To get started using git, you really just need to know a  handful of commands in the beginning:
To get started using git, you really just need to know a  handful of commands in the beginning:


* '''git init''' NAME - to create a completely new empty repository (will not be needed for FG, just for experiments/testing)
; git init ''name'':            Create a completely new empty repository (will not be needed for FG, just for experiments/testing)
* '''git clone''' URL - to create a copy of a git repository locally (that's what you have done already to get the fgdata repository)
; git clone ''URL'':            Create a copy of a git repository locally (that's what you have done already to get the fgdata repository)
* '''git status''' - to view the status of the current repository
; git status:                  View the status of the current repository
* '''git diff''' - to view differences
; git diff:                    View differences
* '''git pull''' - to pull (=download AND merge!) latest updates from the repository that was used for cloning (for updating the local master branch using the origin)
; git pull:                    Pull (=download ''and'' merge!) latest updates from the repository that was used for cloning (for updating the local master branch using the origin)
* '''git pull --rebase''' - to pull and rebase your own changes on top of the pulled data
; git pull --rebase:            Pull and rebase your own changes on top of the pulled data
* '''git branch''' - to show active branch and display list of other local branches
; git branch:                  Show active branch and display list of other local branches
* '''git branch''' BRANCHNAME - to create a new branch using BRANCHNAME (branch=working copy)
; git branch ''branchname'':    Create a new branch using ''branchname'' (branch = working copy)
* '''git checkout''' BRANCHNAME - to checkout a certain branch (i.e. switch to that branch, make it active)
; git checkout ''branchname'':  Checkout a certain branch (in essence switch to that branch and make it active)
* '''git add''' FILENAME - to specify which new or modified files shall be added to the next commit (wildcards supported)
; git add ''filename'':        Specify which new or modified files shall be added to the next commit (wildcards supported)
* '''git commit -m''' "COMMENT" - commit all files that you previously added using "git add" and add a short comment about your work
; git commit -m "''Comment''":  Commit all files that you previously added using "git add" and add a short comment about your work
 


Because creating a new branch and checking it directly afterwards out, is such a common operation there is a short cut available: '''git checkout -b my-branch'''
Because creating a new branch and checking it directly afterwards out, is such a common operation there is a short cut available: '''git checkout -b my-branch'''


 
== Git usage basics ==
To update the base package use '''git pull''' (issued in $FG_ROOT) on the UNMODIFIED master branch (which is the default).
To update the base package use '''git pull''' (issued in $FG_ROOT) on the UNMODIFIED master branch (which is the default).


Line 29: Line 29:
However, assuming that you modify your base package for your own work, it will indeed be better to do this in another branch (i.e. a topic branch), otherwise your own modifications may conflict with the checkout from the server, once you do a git pull so that you will have to manually merge everything. Make sure to use use '''git status''' and/or '''git diff''' on the master branch to see if you have already done any modifications that may complicate the update.
However, assuming that you modify your base package for your own work, it will indeed be better to do this in another branch (i.e. a topic branch), otherwise your own modifications may conflict with the checkout from the server, once you do a git pull so that you will have to manually merge everything. Make sure to use use '''git status''' and/or '''git diff''' on the master branch to see if you have already done any modifications that may complicate the update.


The easiest thing to do would indeed be to locally create a branch of $FG_ROOT, where you save all your work, this can be done using '''git branch BRANCHNAME''', where BRANCHNAME could for example be "local-weather". So just enter the base package folder and type '''git branch local-weather''', you should really be doing this only with a clean/unmodified master branch.
The easiest thing to do would indeed be to locally create a branch of $FG_ROOT, where you save all your work, this can be done using '''git branch ''branchname''''', where ''branchname'' could for example be "local-weather". So just enter the base package folder and type '''git branch local-weather''', you should really be doing this only with a clean/unmodified master branch.


Once you issue then another '''git branch''', you'll see your newly created "local-weather" branch in the list of local branches.
Once you issue then another '''git branch''', you'll see your newly created "local-weather" branch in the list of local branches.
Line 70: Line 70:
Once you understand these basics, I would however suggest to play with modifying and maintaining your scripts in git, it really is fairly and gives you hands on experience, just make sure that it is a copy of the script that you play with first.
Once you understand these basics, I would however suggest to play with modifying and maintaining your scripts in git, it really is fairly and gives you hands on experience, just make sure that it is a copy of the script that you play with first.


For some simple step by step tutorials you may want to check out:
== External links ==
=== Simple step by step tutorials ===
There are obviously many more advanced topics, but this bunch of 3-5 commands should get you going pretty quickly,
things become slightly more interesting, once you want to directly commit to a remote repository or once you need to track and merge multiple branches.


* http://nakedstartup.com/2010/04/simple-daily-git-workflow/
* http://nakedstartup.com/2010/04/simple-daily-git-workflow/
Line 76: Line 79:
* http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
* http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html


=== Online screencasts about doing specific tasks ===
* http://gitcasts.com/


There are obviously many more advanced topics, but this bunch of 3-5 commands should get you going pretty quickly,
=== A bunch of fairly simple beginner tutorials ===
things become slightly more interesting, once you want to directly commit to a remote repository or once you need to track and merge multiple branches.
In order of complexity.
 
Here's a link to online screencasts about doing specific tasks using git: http://gitcasts.com/
 
Here is a bunch of fairly simple beginner tutorials for using git (increasing complexity):


* http://hoth.entp.com/output/git_for_designers.html
* http://hoth.entp.com/output/git_for_designers.html

Navigation menu