1. Base
1.1 New code base
1 2 3 4 5
| git init
git clone [url]
|
Git’s settings file is .gitconfig
, it is usually in the user home directory, for instance C:\Users\[YourUsername]\
1 2 3 4 5 6
| git config --list
git config --global user.name "HardyHu" git config --global user.email 1243971719@qq.com
|
1.3 Add/Delete files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| git add [file1] [file2] ...
git add [dir]
git add .
git add -p
git rm [file1] [file2] ...
|
1.4 Code submission
1 2 3 4 5 6 7 8 9
| git commit -m [message]
git commit [file1] [file2] ... -m [message]
git commit -a
|
1.5 Branch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout -b [branch]
git branch [branch] [commit]
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| git status
git log
git log --stat
git log -S [keyword]
|
1.8 Remote sync
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| git fetch [remote]
git remote -v
git remote show [remote]
git pull [remote] [branch]
git push [remote] [branch]
|
2. Particular Requirement
2.1 Add a repository that only push
, not fetch
.
1
| git remote set-url --add origin <your_repository_url>
|
3. Push an existing repository from the command line
1 2 3
| git remote add origin https: git branch -M main git push -u origin main
|