-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitCommands.txt
173 lines (54 loc) · 2.99 KB
/
GitCommands.txt
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
q ##seems to get me back to last thing - useful for "resetting"
pwd ##Gets current directory
mkdir projects ##creates projects directory
cd projects ##Changes directory to projects
git version ##gives you version of git and confirms installed
git config --global user.name "Richard Griffiths" ##sets user name
git config --global user.name "[email protected]" ##sets e-mail
git config --global ##list returns user name and e-mail above
cat.gitconfig ##sort of do does same as abive
git config --global alias.co checkout ##sets checkout alias, can use co then instead of checkout
git config --global aplply.whitespace nowarn ##ignores differences in whitespace
cat ~bin/ali ##gets aliases directories
cat ~bin/aliases.tcsh ##e.g. gets aliases (see download file from intro to Git for examples)
cd .. ##Goes up on directory
unzip FileLocation/Filename.FileExtension ##Unzips file
ls ##lists items in current directory
git ls-files ##sees files in repostiory
mv CurrentName NewName ##changes name of file/folder
git init ##Initialises git in current directory
ls -al ##lists all items in current directory with details (shows .git folder)
git status ##gives status of git files
git add . ##tracks all files in directory (except for those in .gitignore or exclude)
git add FileName ##tracks filename
##need to add before commit
git commit - m "Message for commit" ## Commits directory to git with message
rm
-rf FileName ##Remove filename
git push origin master ##Pushes changes up to GitHub (after enter username and password when prompted)
##to clone from a github repository, go to git hub and copy HTTPS of the repository then
in git bash...
git clone [Paste the HTTPS here] ##it will make a directory in our current directory
git config ##global core.editor notepad ##changes default text editor to notepad
git
init ProjectName ##initialise project name locally
cd .git ##goes into git folder when in project, do ls command here and can see componenents
notepad FileName.txt ##Initliases text file in project, cand edit and save when opens
git commit -a ##makes git work like file based
git commit - v ##records details of what you actually changed in the commit
git log ##log of what done
git log --stat ##some stats on lines changed, insertions, deletions etc
git log -p
gitk --all ##launches gui
git branch ##gets current branch (coloured) and others
git branch --color ##shows color of curent brancg
git branch BranchName ##creates branch of BranchName
git checkout testbranch ##checks out and changes to testbranch
##Note - when have whatever branch checked out, can onlysee the
##files etc from that branch, including those in the file directory
##make sure know which branch working on!
##you can see the branches in gitk GUI
##may need to resolve own conflicts
git merge BranchName ##merges branches
git rebase master ##applies master to current branch
git reset --hard ORIG_HEAD ##changes back to original after a merge