-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGit-commands
119 lines (58 loc) · 1.5 KB
/
Git-commands
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
configure git with github
git config --global user.name "name"
git config --global user.email "email"
verify it by simply running above commands
cloning a repo
git clone repo url
initialize git repo
git init repo name
view all git repos in terminal
ls -lart
view status
git status
add a file
git add file name (repo directory)
add multiple files or all untracked files
git add -A
commit a file
git commit -m "message"
add a remote repo
git add remote origin repo url
push
git push remote repo url
create a file
touch file name (in repo directory)
edit a file
gedit file name
bring back files from staged environment
git checkout file name
bring back all files from staged environment
git checkout -f
see commits
git log
filter git log output
git log -p -n (number of last commits you want to see)
view the diff from changed file (compares the file in staging area with unstaged area file)
git diff
compare your staging area with last commit
git diff --staged
remove a file from staging area
git rm --cached file name
short status
git status -s
by default your main banch is a master branch
Create branches on git
git branch (branch name)
view branches
git branch
switch to a branch
git checkout branch name
merge a branch
git checkout (branch name)
git merge (branch name that is to be merged)
create and switch to the created branch
git checkout -b (branch name)
push in a master branch
git push - u origin master
Reference
(https://www.youtube.com/watch?v=gwWKnnCMQ5c)