您的位置:首页 > 其它

Git经常使用命令

2017-06-14 12:16 218 查看

总结了一些在工作中频繁用到的Git命令,基本上能够满足需求。

Git事实上非常easy,能用就可以。



1.比較提交 - Git Diff

$ git diff master..test
$ git diff master...test


2.克隆项目 - Git Clone

$ git clone http://git.shiyanlou.com/shiyanlou/gitproject $ git clone /home/shiyanlou/gitproject myrepo


3.提交改动 - Git Add

$ git add newfile
$ git add -u


这个命令的意思是


add to index only files modified or deleted and not those created



仅仅会处理已改动或者已删除的文件。可是不会处理新建的文件

$ git commit -m "add"


4.合并分支 - Git Pull

$ git pull /home/shiyanlou/myrepo master


5.查看改动 - Git Log

$ git log -p master..myrepo/master


6.全局配置 - Git Config

git config --global user.email "keleix@gmail.com"
git config --global user.name "Kallen"


7.完整使用流程

(1) git init

$ git init
$ git pull https://github.com/keleir/BlogProj.git[/code] 

(2) git commit

$ git add *
$ git add LICENSE
$ git commit -m "Initial Commit"


(3) git remote

$ git remote
origin


$ git remote -v
origin  https://github.com/Keleir/BlogProj.git (fetch)
origin  https://github.com/Keleir/BlogProj.ssgit (push)


$ git remote add origin https://github.com/Keleir/BlogProj.git[/code] 

(4) git push

$ git push
Username for 'https://github.com': Keleir
Password for 'https://Keleir@github.com':
Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 1.50 KiB | 0 bytes/s, done.
Total 8 (delta 6), reused 0 (delta 0)
To https://github.com/Keleir/BlogProj.git 47688f3..e22a55b  master -> master


8.FAQ

(1) git push出错

failed to push some refs to 'https://github.com/Keleir/Arigue.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.


【解决的方法】

git pull origin master
git push -u origin master -f


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: