git常用相关操作

// 账号密码克隆远程项目

git clone http://账号:密码@项目地址

// 查看当前状态

git status

// 查看修改内容

git diff

// 添加并提交

git add .  

git  commit -m '注释内容'

// 推送到远程分支

git push origin 分支名

// 拉取远程代码(更新本地代码)

git pull origin 分支名

// 查看历史提交

git log

// 回退到某个版本

git reset --hard 版本号

// 回退到历史版本后,想查看之前的版本

git reflog

// 远程代码强制覆盖本地代码(三步走)

git fetch --all
git reset --hard origin/master
git pull

// 本地代码强制覆盖远程代码

git push origin 分支名 -f

// 切换分支

git checkout 分支名

// 生成分支并切换到新分支

git checkout -b 新分支名

// 主分支a合并分支b

git checkout a 

git pull  // 更新a分支代码

git checkout b

git pull  // 更新b分支代码

git merge a  // b分支先合并a分支

git checkout a

git merge b // a 分支载合并b


猜你喜欢

转载自www.cnblogs.com/yyiyu/p/11365007.html