提交代码一系列操作
进入到要提交的文件夹,右键git Bash
sh
git add .
git status
git commit -m "提交说明"
git pushgit add .
git status
git commit -m "提交说明"
git push提交全部修改文件
sh
git add .
git commit -m "提交说明"git add .
git commit -m "提交说明"提交指定文件/一次性提交多个指定文件
sh
git add path/to/file1 path/to/file2
git commit -m "提交说明"git add path/to/file1 path/to/file2
git commit -m "提交说明"重置add和commit的代码
- 取消暂存(撤销 add)
sh
git reset HEAD path/to/filegit reset HEAD path/to/file- 撤销上一次 commit(但保留修改)
sh
git reset --soft HEAD~1git reset --soft HEAD~1- 撤销 commit 和暂存(保留修改)
sh
git reset --mixed HEAD~1git reset --mixed HEAD~1- 撤销 commit 和修改(危险操作)
sh
git reset --hard HEAD~1git reset --hard HEAD~1拉取指定分支代码
sh
git pull origin 分支名git pull origin 分支名查看所有分支
sh
git branch # 查看本地分支
git branch -r # 查看远程分支
git branch -a # 查看所有分支(本地+远程)git branch # 查看本地分支
git branch -r # 查看远程分支
git branch -a # 查看所有分支(本地+远程)切换分支
sh
git checkout 分支名
git switch 分支名 # 新版命令git checkout 分支名
git switch 分支名 # 新版命令删除指定分支
sh
git branch -d 分支名 # 删除本地分支(已合并)
git branch -D 分支名 # 强制删除本地分支
git push origin --delete 分支名 # 删除远程分支git branch -d 分支名 # 删除本地分支(已合并)
git branch -D 分支名 # 强制删除本地分支
git push origin --delete 分支名 # 删除远程分支新建分支
sh
git branch 新分支名
git checkout 新分支名git branch 新分支名
git checkout 新分支名或者
sh
git checkout -b 新分支名git checkout -b 新分支名查看状态
sh
git statusgit status查看提交日志
sh
git log --oneline --graph --decorate --allgit log --oneline --graph --decorate --all推送分支到远程
sh
git push origin 分支名git push origin 分支名合并分支
sh
git merge 分支名git merge 分支名撤销文件修改(回退到上次提交)
sh
git checkout -- path/to/filegit checkout -- path/to/file
liang14658fox