Git quick reference

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(adding a document draft so it gets found better and has more love)
m (Add git configuration options)
Line 3: Line 3:
 
{{admon/warning|Quick Reference Only|This is not intended to be an exhaustive list of git operations. See the [http://git.or.cz/#documentation documentation] for that.}}
 
{{admon/warning|Quick Reference Only|This is not intended to be an exhaustive list of git operations. See the [http://git.or.cz/#documentation documentation] for that.}}
 
== Basic Operations ==
 
== Basic Operations ==
 +
 +
=== Configure your global git settings ===
 +
Running these commands will setup your global git settings.  You should obviously use your own contact details.  Should you wish to change your details, you can edit the '~/.gitconfig' file for global settings, or edit '.git/config' to change settings on a particular repo.
 +
 +
<code>git-config --global user.name "John Q. Public"</code>
 +
 +
<code>git-config --global user.email "john.public@example.com"</code>
 +
 +
<code>git-config --global color.diff auto</code>
 +
 +
<code>git-config --global color.status auto</code>
 +
 +
<code>git-config --global color.branch auto</code>
  
 
=== Initialize a new repo ===
 
=== Initialize a new repo ===

Revision as of 14:58, 15 October 2008


Warning (medium size).png
Quick Reference Only
This is not intended to be an exhaustive list of git operations. See the documentation for that.

Contents

Basic Operations

Configure your global git settings

Running these commands will setup your global git settings. You should obviously use your own contact details. Should you wish to change your details, you can edit the '~/.gitconfig' file for global settings, or edit '.git/config' to change settings on a particular repo.

git-config --global user.name "John Q. Public"

git-config --global user.email "john.public@example.com"

git-config --global color.diff auto

git-config --global color.status auto

git-config --global color.branch auto

Initialize a new repo

mkdir repo && cd repo && git init

Developer Operations

Create a new local branch

git checkout -b <branch>

Push and create a new remote branch from an existing local branch of the same name

git push origin <branch>

Switch to a branch that was pushed remotely

Use:

git branch -a

to determine the name of the remote branch you want to work on. Remote branches will be preceded by origin/. Then use this to switch to it:

git checkout -b <branch> origin/<branch>

Maintainer Operations

Apply mailed git patch

git am <file>