Git使用的基本命令

Git:

git status

git add 

git commit -m 'message'

git push

mkdir JDoc-s-Project
cd JDoc-s-Project
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin [email protected]:jinbin/JDoc-s-Project.git
git push -u origin master

git pull --rebase

适用场景:改动较小,预期无conflict

1. 把本地repo从上次pull之后的变更暂存起来 

2. 回复到上次pull时的情况

3. 应用远端的变更

4. 应用刚暂存下来的本地变更

可以参考 :http://gitready.com/advanced/2009/02/11/pull-with-rebase.html

git config 

为git仓库配置相关信息,在提交代码时,这些信息会自动反应到git仓库的日志中

git config user.name "bin.jinb"

git config user.email "[email protected]"

git config alias.co checkout  #表示可以用git co代替git checkout, 可以用git var -l 查看已经设置的配置

git reset 

git reset HEAD^ 或者 git reset HEAD^1 撤销最后一次提交

git reset --hard HEAD^ 撤销最后一个提交并清除本地修改

提交本地分支作为远程分支:

git push origin branch : branch

参考文章:http://862123204-qq-com.iteye.com/blog/1683315

猜你喜欢

转载自jdoc.iteye.com/blog/1484317