Git 常用命令 -- 持续更新中

1. 远程仓库相关

1.1 创建远程仓库

$ git init --bare # 在远程环境下执行,需要先创建文件夹

1.2 添加远程仓库

$ git remote add <remote name> <remote url address>

1.3 推送本地分支到远程仓库(创建远程分支)

$ git push <remote name> <branch name>

1.4 获取远程仓库的改动

$ git fetch <remote name>

1.5 同步远程仓库的改动到本地分支

$ git merge <remote branch>

通常可以使用命令 git branch -a 查看远程分支

1.6 删除远程分支

$ gitt push --delete <remote name> <branch name>

1.7 删除本地存在但是远程不存在的那些分支

$ git remote prune <remote name>

1.8 查看远程信息

$ git remote show <remote name>

2. 提交相关

2.1 添加某个目录下的所有改动,包括新增/修改/删除

$ git add --all <dir>

2.2 查看两个提交之间的文件改动

$ git diff --stat <commit1> <commit2>

2.3 创建对应commit的新branch

$ git checkout -b <branch name> <commit/tag/brach_name>

2.4 提交一个空的commit

$ git commit --allow-empty

2.5 提交一个不含message的commit

$ git commit --allow-empty-message

2.6 生成一个空的提交的patch

$ git format-patch -1 --always <commit>

2.7 Git Rebase

$ git rebase -i <commit>
$ git rebase --continue
$ git rebase --abort

2.8 解决 git am 碰到的冲突

$ git am <patch>
$ git apply --reject <patch>
- 根据.rej文件解决冲突 -
$ git add <modify file>
$ git am --resolved

2.9 修改 AuthorDate

git commit --amend --date="<date>"

2.10 修改 CommitDate

GIT_COMMITTER_DATE="<date>" git commit --amend

2.11 修改 Author

git commit --amend --reset-author
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值