git命令行说明

Git tips

  • 设置config信息

1
2
3

$ git config --global user.name sphenginx
$ git config --global user.email sphenginx@sphenginx.com
$ git config --list

  • 生成ssh key

1

ssh-keygen -t rsa -C"sphenginx@gmail.com"

  • 查看config信息

1

git config --list

  • 彩色的 git 输出:

1

git config color.ui true

  • 显示历史记录时,只显示一行注释信息:

1

git config format.pretty oneline

  • 不替换win下的CRLF设置

1

git config core.autocrlf false

  • win下使用https地址的仓库不输入密码设置

1

git config credential.helper wincred

  • 获取我的Github的PHP笔记仓库

1

git clonehttps://github.com/sphenginx/sphenginx.git

  • 设置远程仓库地址

1
2
3
4

git remote -v
git remote --
help
git remote
set origin https://github.com/sphenginx/sphenginx.git
git remote
set-url origin https://github.com/sphenginx/sphenginx.git

  • 正常提交命令

1
2
3
4
5

git status
git pull origin
master
git add .
git commit -am '
提交信息'
git push origin
master

  • 缓存某些修改的文件

1

git stash

  • 恢复缓存的文件

1

git pop

  • 获取某个分支/恢复某个文件

1

git checkout branchX/file_path

  • 撤销某次修改

1

git revert HEAD

  • 回退到某个版本

1

gitreset--hardHEAD|gitreset--hardorigin/master

  • 可以在你的仓库根目录中添加一个叫”.gitignore”的文件,来告诉Git系统要忽略 掉哪些文件,下面是文件内容的示例:

1
2
3
4
5
6
7
8
9

# '#' 开始的行,被视为注释.
# 忽略掉所有文件名是 foo.txt 的文件.
foo.txt
# 忽略所有生成的 html 文件,
*.html
# foo.html是手工维护的,所以例外.
!foo.html
忽略所有.o .a文件.
*.[oa]

  • 删除 untracked files

1

git clean -f

  • 连 untracked 的目录也一起删掉

1

git clean -fd

  • 连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的)

1

git clean -xfd

  • 在用上述 git clean 前,强烈建议加上 -n 参数来先看看会删掉哪些文件,防止重要文件被误删

1
2
3

git clean -nxfd
git clean -nf
git clean -nfd

  • 内建的图形化 git

1

gitk

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值