2017-07-13
by chenyan
tags:
拉取远程仓库并创建自己的分支
- 克隆远程仓库到本地
git clone git://xxxx.git 或者 git clone http:// xxxx.git
- 查看分支
git branch -a
- 切换分支
git checkout xxx
- 创建分支
git branch xxx
- 创建分支并切换到此分支
git checkout -b xxx
提交代码
- 从远端更新到本地
git pull origin xxx
- 查看状态
git status
- 添加到暂存区
git add . 或者 git add xxx
- 提交当前暂存区代码
git commit -m "本次提交注释"
- 提交到远端仓库
git push origin xxx
合并分支
- 合并其他分支
git merge origin/xxx
- 解决冲突后 重新add
其他(很重要!!)
- 删除分支
git branch -d xxx (d只能删除已经参与过merge的分支)
- 强制删除分支
git branch -D xxx
- 查看操作记录
git log
- 重置回上一版本
git reset --hard head (超级有用,误操作之后恢复线上版本)
- 记录所有head的历史
git reflog (可找回reset丢掉的commit)
Share and comment