Format your commit like:
80 character summary
longer description of
changes, maybe include a bulleted
list of changes you made
1 git config --global user.name "Your Name"
2 git config --global user.email "you@your.site"
1 $ git status
2 # Initial commit
3 #
4 # Changes to be committed:
5 # (use "git rm --cached <file>..." to unstage)
6 #
7 # new file: README
8 $ vim README
9 $ git status
10 # Initial commit
11 #
12 # Changes to be committed:
13 # (use "git rm --cached <file>..." to unstage)
14 #
15 # new file: README
16 #
17 # Changes not staged for commit:
18 # (use "git add <file>..." to update what will
19 # be committed)
20 # (use "git checkout -- <file>..." to discard
21 # changes in working directory)
22 #
23 # modified: README
1 $ git commit -m "Added README"
2 [master (root-commit) 4f3ea33] Added README
3 1 files changed, 1 insertions(+), 0 deletions(-)
4 create mode 100644 README
5 <Do more commits>
6 $ git log --oneline
7 773c310 added hello.py
8 7275078 More verbosity for the README
9 4f3ea33 Added README
Protips:
1 # set commit message without opening an editor
2 git commit -m 'commit message'
3 # add only parts of what was changed
4 git add -p
1 $ vim hello.py
2 $ git diff
3 diff --git a/hello.py b/hello.py
4 index 3148dce..33f348b 100644
5 --- a/hello.py
6 +++ b/hello.py
7 @@ -1,3 +1,3 @@
8 #!/usr/bin/env python
9
10 -print "hello world"
11 +print "Hello, world!"
12 $ git commit -am "Fixed up grammar in hello.py"
13 [master 01ee7f3] Fixed up grammar in hello.py
14 1 files changed, 1 insertions(+), 1 deletions(-)
1 $ git log --oneline --decorate
2 1c8ce74 (HEAD, origin/newgitseminar, newgitseminar) Added more on branching
3 4afbe50 Added slides for branching
4 151dd2f Finished converting to vanilla markdown
5 5e130da Added git seminar to front page
6 d219f44 New Git seminar via Landslide now working
7 dfbc19c (origin/master, origin/HEAD, master) Changed length of excerpt
8
9 # specify a branch that is on the remote named 'origin'
10 $ git checkout origin/master
11 # specify a branch name
12 $ git checkout master
13 # specify commit ID (or hash)
14 $ git dfbc19c
15 # specify a commit that is 5 commits prior to where HEAD is
16 $ git checkout HEAD~5
All those checkouts go to the same commit
1 # get the older version of file 'filename'
2 $ git checkout -- filename
3 # throw away all local changes and switch to branch 'master'
4 $ git checkout -f master
use master and develop branches
merge features to develop, then to master
merge hotfixes directly to master as needed
get a branch
1 $ git checkout branchname
create a new branch with name branchname
1 $ git checkout -b branchname
2 #or
3 git branch branchname
4 git checkout branchname
* 5a376b1 - Merge branch 'master' of github.com:boto/boto
|\
| * 2f03097 - Adding ref/dynamodb to hidden TOC.
| * 649bad2 - Merging in @rdodev's DynamoDB tutorial and adapting it for Layer2
| |\
| | * d5defb8 - Little changes
| | * 0a5046c - Starting point. We can add more details later on.
| | * a99fb2e - Grammar fix
| | * d5d3edb - Minor redaction edits
| | * e5a397f - Merge branch 'master' of git@github.com:rdodev/boto.git
| | |\
| | | * 8c19b40 - Fixing code example
| | * | f35a84d - Added subsections
push one of your branches up to a remote
1 $ git push origin testfeature:experimental
to display all local branches
1 $ git branch
2 master
3 * develop
4 feature/newMenuBar
5 hotfix/MVP-449
1 git checkout master
2 git merge experiment
3 < resolve conflicts >
4
5 Hello
6 <<<<<<< HEAD
7 there
8 =======
9 experimental
10 >>>>>>> experiment
11 world
12
13 git commit -m "Merged in my experimental feature"
my personal favorite
1 # unstage a file
2 $ git reset HEAD <filename>...
3 # undo the changes to a file
4 $ git checkout -- <filename>
5 # delete a file from your staging area, but not working directory
6 $ git rm --cached <filename>
7 # view all unstaged changes
8 $ git diff
9 # view all staged changes
10 $ git diff --cached
11 # add a file to your last commit
12 $ git commit -m "A commit"
13 $ git add file_i_forgot.txt
14 $ git commit --amend
15 # see the last 5 days of activity on the repository, concisely
16 $ git log --since=5.days --oneline
1 >> Repository.count(:conditions =>
2 { :parent_id => nil, :public => 1 })
3 => 805411
1 $ git clone git://github.com/some1/project
2 Cloning into project...
3 $ cd project/
4 $ vim README
5 $ git commit -am 'made it better'
6 [master dbeb245] made it better
7 1 files changed, 2 insertions(+), 0 deletions(-)
8 $ (fork it on github)
9 $ git remote add myfork git@github.com:you/project.git
10 $ git push myfork master:feature_name
11 ...
12 To git@github.com:you/project.git
13 9457e38..dbeb245 master -> feature_name
improve someone else's repo, in just one minute
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |