git操作说明

随声附和 提交于 2019-11-29 00:37:37

1.提交代码到远程分支

git branch -a   查看所有分支

git checkout -b xxx  切换到自己的本地分支

git checkout -b xxx origin/QA 创建并切换到QA分支

git add test.cpp   将test.cpp加入到缓存。

git reset HEAD test.cpp   用于取消已缓存的test.cpp内容

git commit -m "update"   将缓存内容加入到仓库。

git status   查看本地仓库有哪些改动。

git push origin mcy:QA    将本地mcy分支推送到远程QA分支。

git push origin head:QA      如果忘记切换到本地分支,可通过此条命令强制提交。

2.删除代码到远程分支

git rm test.cpp

git commit -m "rm test.cpp"

 

3.根据commit id回退代码

git reset --hard 892803238432784727

git show 892803238432784727 查看某次提交内容

 

4.更新代码

git pull origin QA   更新远程分支代码到本地

git pull   默认拉取master代码

git merge origin/master 远程master代码合并到本地 会merge 更安全。

 

5.强制覆盖代码,放弃本地改动

git fetch --all

git reset --hard origin/拉取的分支

git pull //就完成了

放弃本地改动

git checkout .

 

6.查看分支提交的tag和Log情况

git log --oneline --decorate

 

7.分支代码补 tag

git checkout 8888883232

git tag test

git push tags

 

8.查看摸个文件历史记录中都做了哪些修改

git blame 文件

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!