forked from riceonmars/cheat_sheet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit
More file actions
124 lines (86 loc) · 2.58 KB
/
git
File metadata and controls
124 lines (86 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Git cheat sheet
# made while reading Pro Git book
# http://git-scm.com/book
# v 1.0.0
# author: Melita Mihaljevic
# date Feb, 2013
# comment: this is only cheat sheet - read the book for more info
# add username and e-mail address
$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
# check settings
$ git config --list
# get help <verb> - show git man page for <verb>
$ git help add - shows git man pages for add
# initialize git repo
$ git init
# add files to repo
$ git add <filename>
# commit changes
$ git commit -m 'message about commit'
# clone project
$ git clone [url]
$ git://github.com/example/example.git
# check the status of files
$ git status
# get diff
$ git diff
$ git diff --staged - what is staged and will go into next commit
# remove file
$ git rm <filename>
# keep the file in your working tree but remove it from your staging area
$ git rm --cached <filename>
# rename file
$ git mv file_from file_to
# view commit history
$ git log
# commit things you forgot with the last commit
$ git commit --amend
# unstage file
$ git reset HEAD <filename>
# unmodify a modified file
$ git checkout -- <filename>
# which remote servers you have configured
$ git remote -v
# add remote repository
$ git remote add [shortname] [url]
# fetch information from remote repository
$ git fetch [shortname]
# automatically fetch and then merge a remote branch into your current branch
$ git pull
# automatically sets up your local master branch to track the remote master branch on the server you cloned from
$ git clone
# push to server
$ git push [remote-name] [branch-name]
# see more information about a particular remote
$ git remote show [remote-name]
# rename remote reference
$ git remote rename name1 name2
# remove remote reference
$ git remote rm name
# list available tags
$ git tag
# create annotated tag
$ git tag -a [version] -m [message]
# share tag
$ git push origin [tagname]
# create a branch and switch to it at the same time
$ git checkout -b [branch name]
# merge to master
$ git checkout master
$ git merge [branch name]
$ git branch -d [branch name] - delete after merging cause you don't need it anymore
# merge tool
$ git mergetool
# delete remote branch
$ git push [remotename] :[branch]
# check for whitespace errors
$ git diff --check
# squash to a single commit
$ git rebase -i
# when was each line edited and by whom
$ git blame
# binary search through your commit history to help you identify as quickly as possible which commit introduced an issue
$ git bisect start
$ git bisect bad
$ git bisect good v1.0