-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitdemo.txt
101 lines (66 loc) · 1.46 KB
/
gitdemo.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
1. Create a local repo.
git clone https://github.com/lzhao4ever/hello-world.git
git init
git status
git add <file>
git commit -m "Initial import of all project files."
2. Review history
git log --oneline --graph
git reflog
git show <hash#>
3. Branch
git branch --list
git branch --all
git fetch
git checkout --track origin/another-branch
git checkout master
git branch <feature>
git checkout <feature>
git checkout -b <feature>
git rebase master
4. Edit
git add --update
git add --all
5. Remote
git remote add <nickname> <url>
git push -u <nickname> master
git push --set-upstream <nickname> <branch>
git pull --rebase=preserve
git fetch --all
6. Recover
git add <file>
git commit ..
git checkout --<file>
git add <file>
git reset HEAD <file>
git reset <commit#>
git add --all
git clean -fd
git revert <commit#>
git rebase --interactive <commit#>
git merge ...
git reset --merge ORIG-HEAD
7. Review remote
git log --oneline <remote/branch>
git diff <curr-branch> ... <remote/branch>
git checkout --tracking <remote/branch>
8. Merge
git checkout <feature>
vim <file>
git add <file>
git commit -m "..."
git checkout master
git merge --no-ff <feature>
git cherry-pick -x <commit#>
git branch --delete <feature>
9. Routine
git checkout master
git pull --rebase=preserve
git checkout <feature>
git rebase master
vim ...
git add ...
git commit ...
git checkout master
git merge --no-ff <feature>
git push