您的位置:首页 > 其它

git实用命令集锦

2015-07-02 09:22 260 查看
配置用户名、邮件:

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