forked from 7788wangzi/Introduction-to-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitCmdline.txt
102 lines (71 loc) · 2.17 KB
/
gitCmdline.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
centralized version control
distributed version control - git
git:
each computer store a full database, you don't need to connect to server to get a file or update a file.
server - reprository
|
| |computer1 - repository
database |computer2 - repository
|computer3 - repository
git three main states: committed, modified, staged
committed means that the data is safely stored in your local database
modified means that you have changed the file but have not committed it to your database yet.
staged means that you have marked a modified file in its current version to go into your next commit snapshot.
command-line:
----
git status
-staging and commit
git add <file>
git commit -m "comment goes here"
-skip staging, directly commit
git commit -a -m "comment goes here"
git diff --staged
git diff --cached
----
git rm <file>
-untrack a file
git rm --cached <file> -f
-rename
git mv <fileA> <fileB>
git commit -m "comment goes here"
-view committed version
git log
git log -p -2
git log --stat
git log --pretty-oneline
git log --pretty:format:"%h %an, %ar : %s"
git log --since=1.weeks
-unstage a staged file
git reset head <file>
-unmodifying a modified file
git checkout --<file>
--work with remote
-clone a remote repository, cd to the expected path in local, then run:
git clone https://github.com/7788wangzi/git_ws10.git
-check remote version
git remote -v
-push local update to remote
git push [remoteName] [localBranchName]
-pull remote repository to local
git pull [remoteName] [localBranchName]
--add remote repository
git remote add [name] [url]
git remote add origin https://github.com/7788wangzi/git_2.git
-stop mapping
git remote rm origin
-create local branch
git branch [branchName]
git branch 117
-switch to branch 117
git checkout 117
-sync branch to remote
git push origin 117
-delete remote branch
git push origin :heads/117
-delete local brach
git branch -d 117
-get a specific branch from server (for clone project only)
git branch -b 1118 origin/1118
-merge a branch to current branch
git merge 1118
Note: git status only check the diff of his local version with the last push version of his own, it doesn't identify the changes pushed by other people.