-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgit-cheatsheet
246 lines (183 loc) · 5.72 KB
/
git-cheatsheet
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Installing xclip for copy to clipboard
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release*rpm
sudo yum -y install xclip
github - adding ssh key - use xclip in place of clip
xclip -sel clip < ~/.ssh/id_rsa.pub
https://help.github.com/articles/generating-ssh-keys
Enabling port for git (TCP 9418) in cpanel
Plugins > ConfigServer Security & Firewall
Firewall configuration
TCP_IN & TCP_OUT - 9418
TCP_OUT - 22
---------------
check if ssh is working fine
https://help.github.com/articles/error-permission-denied-publickey
http://unix.stackexchange.com/questions/48863/ssh-add-complains-could-not-open-a-connection-to-your-authentication-agent
ssh -vT [email protected]
ssh-add -l
Could not open a connection to your authentication agent
eval "$(ssh-agent)"
ssh-add -l
Error: Permission denied (publickey)
ss-add /path/to/key (id_rsa)
ssh-add -l
Add the id_rs.pub key to github account
ssh -vT [email protected]
Hi vinodpandey! You've successfully authenticated, but GitHub does not provide shell access.
---------------
Git in 15 minutes
http://try.github.com/levels/1/challenges/1
Branching Demo
http://pcottle.github.com/learnGitBranching/
http://pcottle.github.com/learnGitBranching/?demo
http://pcottle.github.io/learnGitBranching/index.html
GUI client
http://sourcetreeapp.com/
======================
Github
=====================
git status
git commit -m "Comment text"
git branch
git remote -v
git pull
git push origin master
origin - remote branch
master - local branch
==
git add file_name
git commit -m "message"
git pull
git push origin master
===
Solving conflicts
------------------
git pull
- error message - conflict error in files
fix the local conflicts and files
commit the changes in files with conflict (git commit ..)
git push origin master
=========================
tagging
---------
show tags:
git tag
create tags (annotated):
git tag -a v1.4 -m 'version 1.4'
push tags to remote server:
git push --tags
working on tag:
git checkout <tag_name>
Git branching model
Ref: http://nvie.com/posts/a-successful-git-branching-model/
First time
-----------
git clone [email protected]:vinodpandey/test-git-flow.git master-repo
cd master-repo
git branch (will show current branch)
* master
create a develop branch
git branch develop
git branch
* master
develop
push develop branch content to remote repo
git checkout develop
git push origin develop
checking out develop from remote server
git pull
git branch -r
git checkout -b develop origin/develop
regular development/bug fixes in develop branch
git checkout develop (switch to develop branch)
git pull origin develop (take lastest changes from remote server regularly)
git add {changed files}
git commit -m "commit message"
git push origin develop (push changes to remote server)
Temporary branches that will be removed eventually
1. Feature branch - feature for upcoming/distant future release
2. Release branch - support preparation of a new production release
3. Hotfix branch - for fixing severe production defects
Feature branch
---------------
may branch off: develop
must merge back to: develop
creating a feature branch
$ git checkout -b myfeature develop
make this branch available to everyone (so that we have the latest code on feature branch - bus factor)
$ git push origin myfeature
during development
$ git add {chanegd files}
$ git commit -m "message"
$ git push origin myfeature
incorporating finished feature on develop
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
$ git push origin develop
Release branch
--------------
may branch off from: develop
must merge back to: develop and master
naming convention: release-*
- branch off when develop reflects desired state of the new release
- this branch will be deployed on QA, STAG and then production
- no new feature should be added to this branch. only fixes for bugs found in QAT, UAT
creating a release branch
see previous release versions (release tags) to decide the current release version
$ git tag -l (based on the latest tag, create a new major, minor release branch below)
$ git checkout -b release-1.2 develop
push this to remote server (for others to work on it, will be deleted later)
$ git push origin release-1.2
- fix minor bugs found during QAT, UAT
- no new feature
finishing a release branch
$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2 -m 'version 1.2'
push tags to remote server:
$ git push --tags
$ git push origin master
merge changes back to develop
$ git checkout develop
$ git merge --no-ff release-1.2
$ git push origin develop
remove the release branch from remote
$ git push origin :release-1.2
remove the release branch (locall)
$ git branch -d release-1.2
Deploy tag 1.2 on server
Hot Fix
-------
includes quick production fix
branch off from: master
merge back to master and develop
creating hotfix branch
$ git checkout master
find out the current release tag
$ git tag -l
create a hotfix version name based on the latest tag above (e.g. 1.2 for below naming convention)
$ git checkout -b hotfix-1.2.1 master
checkin the fix
$ git add {files changed}
commit the fix
$ git commit -m "Fixed severe production problem"
merging changes back to master and creating tag
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
push tags and changes to remote server:
$ git push --tags
$ git push origin master
merge the changes to develop branch
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
$ git push origin develop
delete the temporary branch
$ git branch -d hotfix-1.2.1
## Branches
fetch all branches
git fetch --all
git branch -a
git checkout branch