git实用命令集锦

配置用户名、邮件:

$ git config --global user.name "Your Name"

$ git config --global user.email "email@example.com"


忽略某些文件:(如果不管用,就放到项目根目录下)
~/.gitconfig


忽略stage步骤,直接提交:
$ git commit -a -m 'added new benchmarks'


删除文件(同时从仓库和文件系统删除):
$ git rm -f grit.gemspec


移动(或重命名)文件:
$ git mv file_from file_to


查看提交历史纪录:
$ git log --pretty=oneline


看最近两周的提交历史纪录:
$ git log --since=2.weeks


忘了提交某个文件:(下面的三条命令最终只是产生一个提交,第二个提交命令修正了第一个的提交内容)
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend


丢弃修改:
$ git checkout -- benchmarks.rb


查看当前配置有哪些远程仓库:(如果有多个远程仓库,此命令将全部列出)
$ git remote -v


创建、切换分支:
$ git branch
$ git checkout testing


新建一个bug分支,fix之后,merge到master分支,并删除改bug分支:
$ git branch iss53
$ git checkout iss53
$ vim index.html
$ git commit -a -m 'added a new footer [issue 53]'
$ git checkout master
$ git merge iss53
$ git branch -d iss53
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值