git使用的一些小技巧

一番码客 : 挖掘你关心的亮点。
http://efonfighting.imwork.net

本文目录:

cherry-pick 多个commit

git cherry-pick commitid1…commitid100 (不包含第一个commitid)

查找丢失的commit

git fsck --lost-found

git status 中文乱码

git config --global core.quotepath false

git format-patch

1)两个节点之间的提交: [git format-patch 节点A 节点B]
2)单个节点: [git format-patch -1 节点A] (-n就表示要生成几个节点的提交)
3)最近一次提交节点的patch :[git format-patch HEAD^] 依次类推……
git am *.patch //生成提交节点
git apply *.patch //只修改文件,不生成提交节点

强推

//刚刚push到远端还没有人其他人下载或改动的:
git commit --amend
git push --force-with-lease

//其他人已经下载或改动:
git fetch origin
git reset --hard origin/master

分支操作

git push origin local_branch //推送本地新建分支到远程分支
git push --delete origin local_branch //删除远程分支
git branch -m oldname newname //本地分支重命名

git branch -r -D origin/BranchName //删除本地的远程分支
git push origin -d BranchName //远程删除git服务器上的分支

git diff

git diff branch1 branch2 --stat //显示出所有有差异的文件列表
git diff branch1 branch2 文件名(带路径) //显示指定文件的详细差异
git diff branch1 branch2 //显示出所有有差异的文件的详细差异


最大文件大小限制

git config --global pack.packSizeLimit 512m


git status

git status -uno [man git-status] //只显示当前代码库已有的文件状态


删除tag

显示本地 tag
git tag
Remote_Systems_Operation
删除本地tag
git tag -d Remote_Systems_Operation
用push, 删除远程tag
// git push origin :refs/tags/Remote_Systems_Operation
git push --tags


gitignore 修改不起作用

git rm -r --cached .
git add .
git commit -m “update gitignore”


windows下创建.gitignore:

因为windows将.gitignore识别为了文件类型后缀,不让创建没有名字的文件,所以只用用linux环境touch命令。两种途径:

  • git bash
  • win10 ubuntu

免费知识星球: 一番码客-积累交流
微信公众号:一番码客
微信:Efon-fighting
网站: http://efonfighting.imwork.net

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一番码客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值