Difference between revisions of "GIT Cheat Sheet"

From Tmplab
(Basic commands: local)
(Remote commands)
Line 23: Line 23:
 
  git ls-files
 
  git ls-files
 
  git ls-tree HEAD
 
  git ls-tree HEAD
 +
 +
= Remote commands =
 +
 +
== Creating an empty project on a remote machine ==
 +
 +
For first import into a GIT server for example:
 +
 +
ssh username@yourcheaphost.com
 +
mkdir -p ~/git/yourproject.git
 +
cd ~/git/yourproject.git
 +
git --bare init
 +
 +
And then on the local machine:
 +
 +
mkdir yourproject
 +
cd yourproject
 +
git init
 +
git remote add origin ssh://username@yourcheaphost.com/~/git/yourproject.git
 +
touch .gitignore
 +
git add .
 +
git commit -m "Initial Commit"
 +
git push origin master
 +
 +
and add this to your .git/config in your project.
 +
 +
[branch "master"]
 +
  remote = origin
 +
  merge = refs/heads/master
 +
 +
 +
== Get a copy of a project ==
 +
 +
git clone gitservername:proj1 proj1
  
 
= References =
 
= References =

Revision as of 00:15, 2 March 2009

Basic commands (local)

Creating

git init

Adding files

git add <filename>

or to commit all files in current directory:

git add .

Committing changes

git commit -m <message>

Seeing changes

git log

Tagging

Adding a tag

git tag <tagname> -m "Comment about this tag"

Listing tags with comments

git tag -n

Seeing files inside repository

git ls-files
git ls-tree HEAD

Remote commands

Creating an empty project on a remote machine

For first import into a GIT server for example:

ssh username@yourcheaphost.com
mkdir -p ~/git/yourproject.git
cd ~/git/yourproject.git
git --bare init

And then on the local machine:

mkdir yourproject
cd yourproject
git init
git remote add origin ssh://username@yourcheaphost.com/~/git/yourproject.git
touch .gitignore
git add .
git commit -m "Initial Commit" 
git push origin master

and add this to your .git/config in your project.

[branch "master"]
  remote = origin
  merge = refs/heads/master


Get a copy of a project

git clone gitservername:proj1 proj1

References