Git常用命令

来源:互联网 发布:网络控制器是干嘛的 编辑:程序博客网 时间:2024/05/16 10:19

总结了一些在工作中频繁用到的Git命令,基本上可以满足需求;
Git其实很简单,能用即可。

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

(2) git commit

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

(3) git remote

$ git remoteorigin
$ git remote -vorigin  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

(4) git push

$ git pushUsername for 'https://github.com': KeleirPassword 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 behindhint: 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

热门推荐

  • LNMP环境搭建——Nginx篇

  • 在RHEL6.5中配置本地YUM源

  • Ubuntu下Zabbix安装及使用问题

  • MySQL双主热备问题处理

  • Rsync同步错误处理

  • Fix Elementary Boot Screen (plymouth)
    After Installing Nvidia Drivers

  • LNMP环境搭建——MySQL篇
  • Shell Step by Step (3) —— Stdin & if
  • Shell Step by Step (4) —— Cron & Echo
  • LNMP环境搭建——PHP篇
0 0
原创粉丝点击