forked from discover-devops/DevOps_Workbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GIT_Commands.txt
180 lines (135 loc) · 2.64 KB
/
GIT_Commands.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
174
175
176
177
178
179
180
Installation
apt-get install git-all
git --version
Configuring Git
git config --global user.name "Your_Name"
git config --global user.email "Your_Email"
git config --global core.editor "Path_of_Editor_SW"
git config --list
Creating Repositories
mkdir /your_project_dir
cd /to_your_project_dir
ls -lart
git init
git status
ls -lart
rm -rf .git
git status
git init
mkdir /your_2nd_project_dir
cd /to_your_project_dir
vi README
vi Hello.py
cd ..
git init /your_2nd_project_dir
cd /your_2nd_project_dir
git status
Making and Recording Changes
git add Hello.py
git status
git commit -m "Commiting Hello File"
git status
vi Hello.py
git status
git diff
git add Hello.py
git status
git commit -m "Modified Version of Hello"
git status
git add README
git status
git commit -m "Commiting the README"
git status
git rm Hello.py
git rm --cached Hello.py
git status
Ignore files
touch .gitignore
git status
echo "Hello.py" > .gitignore
cat .gitignore
git status
git add .gitignore
git status
git commit -m "GitIgnore Commit"
git status
git ls-tree -r master --name-only
git add Hello.py
git status
git commit -m "hellp.py Second time "
git status
Viewing History
git log
git log
git log --stat
git log -n
git log --after
git log --oneline
git revert <commit_id>
Undoing
echo "This is a temp file" > tmp.txt
git status
git add tmp.txt
git status
git commit -m "Temp File "
git status
git rm tmp.txt
git status
git commit -m "Deleteing the tmp file"
git status
git revert <commit_id>
git ls-tree -r master --name-only
vi Hello.py
git status
git checkout -- <file>
Unstaging
touch file1.txt
git status
git add file1.txt
git status
git reset HEAD file1.txt
git status
Uncommitting
git commit -m "file1.txt Commit Operation"
Remote Repo
git clone <https://>
git log --online
git reset --hart <commit_id>
GIT BRANCHES
git branch
git branch b1 master
git checkout b1
git branch
vi fileb1.txt
git status
git add fileb1.txt
git status
git commit -m "This sfor branch b1"
git status
git log --oneline
git checkout master
git branch
git log --oneline
GIT Branch Merging
git merge src dest
git merge b1 master
ls
git log --oneline
Branch Delete
git branch -d b1
Rename Branch
git branch -m <old branch name><new branch name>
Remote Libraries
Create a remote repsitory at gitHUB
git remote add origin https://
git remote -v
git push origin master
git push origin b1
Copy from the remote
mkdir /remoteproj
cd /remoteproj
git clone URL
ls -la
git remote -v
git fetch origin
git pull origin