1. Clone the project to local
git clone https://github.com/raikay/gittest.git
2. Pull the latest
git pull
3. Add files to the temporary storage area
git add 文件名 # 指定文件。
git add . # 将当前工作区的所有文件都加入暂存区
4. Submit the contents of the cache area to the local warehouse
git commit -m "提交说明"
git commit --amend #追加/修改上次提交、不新增提交记录
5. View the status of the workspace and cache area "git status"
git status
6. Push to the remote branch
git push
git push origin branch1 #多个仓库时,指定origin仓库下 branch1分支
7. Get help "help"
git 命令 -h
8. Force local coverage
// 从远程仓库下载最新版本
git fetch -all
// 将本地设为刚获取的最新的内容
git reset --hard origin/master
9. Initialization of existing projects locally
- Initialize the basic file:
git init
- Add to staging area:
git add .
- Submit to the local warehouse:
git commit -m 'init'
- Add remote remote warehouse address:
git remote add origin https://github.com/raikay/gittest.git
- Push to remote warehouse:
git push -u origin master
-u
: Create an upStream upload stream, which is only created when the code is pushed for the first time, and there is no need to add-u
parameters later
related articles
git command memo series (1): basic commands
git command memo series (two): configuration file operation (config)
git command memo series (3): view history (log)
Git command memo series (four): compare the differences between two branches (diff)
Git command memo series (5): restore and undo (reset)
git command memo series (6): branch operation (branch)