-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.txt
More file actions
71 lines (55 loc) · 1.99 KB
/
git.txt
File metadata and controls
71 lines (55 loc) · 1.99 KB
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
1. create the develop branch from master
git checkout -b develop master
2. add this file
1 file : git add git.txt
2 files : git add git1.txt git2.txt
a folder : git add folder_name
current folder : git add .
3. commit change to local repo
all changes in workspace : git commit -m "Test Git flow"
specified files : git commit git1.txt git2.txt -m "Test Git flow"
4. commit change to remote repo directly
all changes : git commit -a -m "Test Git flow" ; git push ;
equal to : git add . ; git commit . -m "Test Git flow" ; git push ;
5. merge change to master branch from develop branch
switch to master : git checkout master
merge change : git merge develop
6. list all branch
all local branches : git branch
all remote branches : git branch -r
all local/remote branches : git branch -a
7. create the remote branch - develop as the upstream branch
git checkout develop
git push --set-upstream origin develop
git branch --set-upstream-to=origin/develop
git push --set-upstream origin feature/[branch]
8. push change to remote branch
git checkout develop
git push
9. set push for current branch only
git config --global push.default simple
10. merge develop into master and origin/master
git checkout master
git merge develop
git push
git push origin master
11. merge remote branch into local branch
git checkout master
git pull
for remote master to develop : git pull origin master
for different branch : git fetch origin master:develop ; git diff develop ; git merge develop
12. revert all local changes
revert all directly : git reset --hard
revert the specified file : git reset [file]
revert all and checkout from local repo : git checkout .
13. show all changed files
git status
14. simply show diff for the workspace
git diff
15. create a feature branch
create branch and then stay as before : git branch [branch]
create branch and then switch to it : git checkout -b [branch]
16. delete the branch
git branch -d [branch]
force delete : git branch -D [branch]
delete remote branch : git push origin --delete [branchName]