git常用操作

6次阅读

共计 491 个字符,预计需要花费 2 分钟才能阅读完成。

常用命令

# 代码下载
git clone xxxxxx
# 日志
git log
# 代码回退
git reset --hard 提交 id

# 缓存管理
git stash list
git stash drop stash@{0}
git stash clear

# 查看状态 
git status

# 本地分支管理    
# 创建
git checkout -b 本地分支名 远程分支名
git checkout -b 本地分支名 -t 远程分支名
# 查看
git branch -a
git branch
# 删除
git branch -d 分支名
# 切换
git checkout 分支名
# 合并 分支 A 合并到 B
git checkout B
git merge A

# 代码回退
# 回退到某个版本
git reset --hard <commit_id>
git push origin HEAD --force
# 回退本地 commit
git reset HADE
git push origin developer --force
# 逆向提交本地 commit
git revert HADE
git add
git commit
git push

代码提交流程

# 缓存本地修改
git stash 
# 拉取远程代码
git pull
# 提取本地缓存
git stash pop
# 解决冲突、提交代码 
正文完
 0