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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
| # git config # git config -l git config --list git config --list --global git config --list --local # git config -e --global git config -e --local # git config --global user.name [name] git config --global user.email [email] git config --local user.name [name] git config --local user.email [email] # git config --global --add [key] [value] git config --local --add [key] [value] # git config --global --get [key] [value] git config --local --get [key] [value] # git config --unset --global user.name git config --unset --global user.email git config --unset --local user.name git config --unset --local user.email
# git init/clone # git init # git init [dir] # git clone [url] git clone [url] [dir] git clone [url] -b [branch] [dir] git clone --depth 1 [url] -b [branch] [dir]
# git remote # git remote -v git remote show [remote] # git remote add [remote] [url] # git remote rename [old-remote] [new-remote] # git remote remove [remote] # git remote set-url [remote] [url] # git pull [remote] [branch] git pull --rebase [remote] [branch] git pull --no-rebase [remote] [branch] git pull --merge [remote] [branch] git push [remote] [branch] git push [remote] --force git push [remote] --all # git revert [commit-id] # git revert [commit-id] --no-edit
# git fetch git fetch [remote] git fetch [remote] [branch]
# git checkout # git checkout [branch] # git checkout -b [branch] git checkout -b [branch] [commit-id] git checkout -b [branch] [tag] # git checkout - # git checkout --track [remote]/[branch] # git checkout [path] # git checkout [commit-id] [path] # git restore [path] git restore --staged [path] git restore --source [commit-id] [path]
# git reset # git reset [path] git reset --mixed [path] # git reset [commit-id] git reset --mixed [commit-id] # git reset --hard # git reset --soft [commit-id] # git reset --hard [commit-id] # HEAD # current version HEAD^ | HEAD~1 # last version HEAD^^ | HEAD~2 # 2 versions before HEAD^^^ | HEAD~3 # 3 versions before # git reset --soft HEAD~ git reset --soft [commit-id] # git reset --hard [commit-id]
# git branch # git branch git branch -v git branch -r git branch -a # git branch [branch] git branch [branch] [commit-id] # git branch --track [branch] [remote-branch] # git branch --set-upstream [branch] [remote-branch] # git branch -m [old-branch] [new-branch] # git branch -M [old-branch] [new-branch] # git branch -d [branch] # git branch -D [branch] # git branch -dr [remote]/[branch] git push [remote] --delete [branch] # git merge [branch] git merge --no-commit [branch] git merge --continue git merge --abort # git cherry-pick [commit-id] git cherry-pick --no-commit [commit-id] git cherry-pick --continue git cherry-pick --skip git cherry-pick --abort # git rebase [branch] git rebase -i [branch] git rebase [branch1] [branch2] git rebase --continue git rebase --skip git rebase --abort
# git add # git add [path] git add [path1] [path2] ... git add . # git add -u [path] git add --update [path] # git add -A [path] git add --all [path] # git add -i [path] git add --interactive [path]
# git rm/mv # git rm [path1] [path2] ... # git rm --cached [path] # git mv [file] [new-file]
# git commit # git commit git commit -m [message] git commit -v # git commit -a -m [message] # git commit --amend git commit --amend -m [message] git commit --amend --author [author] git commit --ammend [path1] [path2] ...
# git diff/show # git diff git diff --name-only # git diff --cached git diff --staged # git diff [commit-id] git diff HEAD # git diff [branch1] [branch2] git diff [branch1]...[branch2] git diff [branch1] [branch2] -- [file] # git show git show [commit-id] git show --name-only [commit-id] git show [commit-id]:[file]
# git status git status
# git stash git stash git stash list git stash pop git stash drop # git stash push -p
# git log # git log git log --stat git log --oneline git log --pretty git log [commit-id] git log -[number] git log [tag] HEAD --pretty=format:%s git log -n1 -p # git log -S [keyword] # git log --follow [file] git whatchanged [file] git log -p [file] # git shortlog -sn # git blame [file] # git reflog git reflog show [branch] git reflog show main@{0} git reflog show --all git reflog stash git diff stash@{0} main@{0} git diff main@{0} main@{1.day.ago}
# git tag # git tag # git tag [tag] git tag [tag] [commit-id] git tag -a [tag] -m [message] [commit-id] # git checkout [tag] # git show [tag] # git tag -d [tag] # git push [remote] --delete [tag] # git push [remote] [tag] git push [remote] --tags
|