Git之命令总结

来源:互联网 发布:刘德华 17岁 知乎 编辑:程序博客网 时间:2024/05/02 03:07

预热工作

初始化本地仓库

git init

配置账号等信息

git config –global user.email “you@example.com”
git config –global user.name “Your Name”

添加、提交修改

git add .
git commit -m ‘备注信息’

查看提交信息

git log

查看历史提交

git reflog

版本回滚

git reset –hard 版本号

个人修复BUG

单人处理:

git stash 将当前工作内容暂存到别处,返回上一个commit

Use git stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD commit.

git stash pop 将别处暂存内容取回

这个讲的挺详细:

http://blog.csdn.net/wh_19910525/article/details/7784901

企业处理:

git branch dev 建立分支
git branch fixbugs
git branch -d fixbugs
git checkout fixbugs 切换分支
git merge fixbugs 在master分支下合并修改bug的代码

远程仓库

git add .
git commit -m ‘备注信息’
git remote add origin https://…
git push origin master origin 相当于远程仓库别名,master是远程仓库的master分支

第一次从远程仓库拉下代码:

方式一:

git clone https://…

方式二:

git init
git remote add origin https://…
git pull origin master

方式三:

git init
git remote add origin https://…
git fetch origin master
git merge origin/master

第二次以后拉代码:

git pull origin master

或者

git fetch origin master
git merge origin/master

上述两者是等价的!!!

原创粉丝点击