-
Notifications
You must be signed in to change notification settings - Fork 2
/
GIT.txt
84 lines (62 loc) · 2.95 KB
/
GIT.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
GIT - version control system
git init | git init [folder] // Turn an existing directory into a git repository
git clone [repo URL] | git clone [repo URL] [folder] // Clone an existing repository including files, branches and commits
git add [directory | file] // add directory or file to staging area
git commit -m "[message]" // commit staged changes to local repository with specified message
git commit -m "[message]" --no-verify // commit without verification
git push // push changes to remote
git push —u origin [] // push to the right remote repo and branch
git commit --amend -m "[message]" // amend last pushed commit
git push -f // force push to amend commit remote
git status // show changes; staged, unstaged, untracked
git log // display history of commit
git diff // show changes
git fetch // retrieve changes from remote without merging
git stash // save edited files out of current changes (useful when pulling new changes from remote)
git stash -a // stash all files
git stash -u // stash untracked files too
git stash pop // get the stash back
git pull // retrieve changes from remote and merge to local
git branch // list branches
git branch [branchname] // create a branch with the specified name
git branch -d [branchname] // delete the specified branch
git push origin —delete [branchname] // delete remote branch
git checkout [branchname] // switch to specified branch
git merge [origin/branchname] // merge current branch with specified branch (merge all at once)
git rebase [origin/branchname] // rebase current branch with specified branch (merge commit by commit)
git revert [commit] // create new commit undoing changes from specified commit
git reset --soft HEAD~1 // undo last commit keeping changes (~x number of commits to revert)
git reset HEAD~1 // undo last commit without keeping changes
git reset --hard [origin/branchname] // reset branch following remote
git config --global user.name [name] // change config name
git config user.name [name] // change config name for this folder
git config --global user.email [email] // change config mail
git config user.email [email] // change config mail for this folder
/!\ It is crucial to keep sensible files (passwords, API, config, etc.) in a .gitignore file
/!\ And useless files as well
.env
/node-modules
Master branch handle the working code
Hotfix branch handle random bugs
Release branch handle last check before new release
Develop branch handle improvements to the code, including new features
Feature branches handle new features to be add to develop
ALIAS
// reach and edit list with => git config --global -e
// git cm "anything"
// git cmt "add" "anything"
co = checkout
br = branch
ci = commit
cm = commit -m
cmt = "!f() { git commit -m \"[$1] $2\"; }; f"
st = status
stu = stash -u
stp = stash pop
stl = stash list
reb = rebase
reb-main = !git stash -u && git rebase origin/main && git stash pop
reb-qual = !git stash -u && git rebase origin/qual && git stash pop
mer = merge
pu = push
pl = pull