Difference between revisions of "Git"

From Christoph's Personal Wiki
Jump to: navigation, search
(External links)
(Examples)
Line 5: Line 5:
 
==Examples==
 
==Examples==
 
===Basic===
 
===Basic===
*Quick help
+
* Quick help:
  git help      # returns most common commands
+
  $ git help      # returns most common commands
  git help -a  # get a list of all installed git commands
+
  $ git help -a  # get a list of all installed git commands
  man git-add  # man page on the 'add' command
+
  $ man git-add  # man page on the 'add' command
*Start a new git repository:
+
 
  mkdir my_new_project && cd my_new_project
+
* Start a new git repository:
  git init
+
  $ mkdir my_new_project && cd my_new_project
 +
  $ git init
 
  # create some new files, then:
 
  # create some new files, then:
  git add .
+
  $ git add .
  git commit
+
  $ git commit
*See what has changed since last commit:
+
#~OR~
  git diff
+
$ git commit -am 'initial commit message'
*A more concise way to view what has changed and what needs to be done
+
 
  git status
+
* See what has changed since last commit:
 +
  $ git diff
 +
 
 +
* A more concise way to view what has changed and what needs to be done:
 +
  $ git status
  
 
===git-svn===
 
===git-svn===
The following three commands will import a remote [[svn]] repository into a local git repository.
+
* The following three commands will import a remote [[svn]] repository into a local git repository:
  mkdir pymmlib && cd pymmlib
+
  $ mkdir pymmlib && cd pymmlib
  git svn init -t tags -b branches -T trunk <nowiki>https://pymmlib.svn.sourceforge.net/svnroot/pymmlib</nowiki>
+
  $ git svn init -t tags -b branches -T trunk <nowiki>https://pymmlib.svn.sourceforge.net/svnroot/pymmlib</nowiki>
  git svn fetch
+
  $ git svn fetch
  
 
==See also==
 
==See also==

Revision as of 21:16, 18 February 2016

Git is a distributed revision control / software configuration management project created by Linus Torvalds, initially for the Linux kernel development.

Git is by far my favourite revision control system. I not only use it for software management, I also use it as my backup system for any of my text files.

Examples

Basic

  • Quick help:
$ git help      # returns most common commands
$ git help -a   # get a list of all installed git commands
$ man git-add   # man page on the 'add' command
  • Start a new git repository:
$ mkdir my_new_project && cd my_new_project
$ git init
# create some new files, then:
$ git add .
$ git commit
#~OR~
$ git commit -am 'initial commit message'
  • See what has changed since last commit:
$ git diff
  • A more concise way to view what has changed and what needs to be done:
$ git status

git-svn

  • The following three commands will import a remote svn repository into a local git repository:
$ mkdir pymmlib && cd pymmlib
$ git svn init -t tags -b branches -T trunk https://pymmlib.svn.sourceforge.net/svnroot/pymmlib
$ git svn fetch

See also

External links