Git

分类下相关文章

从 Git 仓库中删除指定 commit

最近接了一个客户的项目,是用 ecshop 写的,长期没有人维护,现在想做改版。 ecshop 所用的版本是 2.7.3, 只支持 PHP 5.2 (ecshop 3.0 支持了 PHP 5.6)。在我的开发机 Ubuntu 16.04 上,使用 phpbrew 死活装不上 PHP 5.2;实际上可以,主要是时间紧,下午还要和客户见面,我实在不想花时间去打 patch。于是就在同事用 phpstudy 搭建的测试环境里直接调试、提交修改了。 问题出现了。在我开发机上,实际上有一点改动,但是与测试环境的代码 merge 之后,导致测试环境无法运行。明显是我开发机改错了东西。现在想把这次 merg ...

阅读全文...

coding.net 无法识别 pub key 的问题

我在几台服务器上都遇到了这个问题,不知道什么原因,coding.net 就是识别不了本机生成的 pub key. 但是同样的 key 在 bitbucket 和 github 上都没有问题。 一种简单粗暴的方式是 git config --global credential.helper store 但是这是一种非常不安全的方式,因为账号和密码会明文保存到用户根目录下的文件 ~/.git-credentials 中。 Using this helper will store your passwords unencrypted on disk, protected only by file ...

阅读全文...

HTTP 访问 git server 时的免密码操作方法

有时必须采用 http 协议操作,提交代码时异常痛苦。介绍下免密码操作的方法。 简易但不安全的方法 用户根目录下新建一个 .netrc 文件, 相关参数改成自己的即可。 machine git-server-ip-or-host login your-accout password your-password protocol http 控制权限,防止偷窥 chmod 0600 .netrc 更安全的方法 使用 gpg 对 .netrc 进行加密。 生产一个 gpg key gpg --gen-key 按照提示输入即可,最后一步可能耗时很长,静候几分钟即可。 进行加密 gpg -e ...

阅读全文...

拉取 Git 远端分支

例如,我要拉取远端其他小伙伴提交的新分支 test git fetch git checkout -b test origin/test 参考 Checkout remote Git branch ...

阅读全文...

通过代理访问 Git 仓库

背景 近期 BitBucket 被墙,无法推拉我的私有项目代码 解决方法 通过 GoAgent 代理访问 BitBucket Git 仓库. 假设 GoAgent 本地代理的端口号是 8087 (默认) 具体配置: 在 .git/conf 文件里添加 [http] proxy = http://127.0.0.1:8087 同时修改 [remote "origin"] url = ssh://git@bitbucket.org/<username>/<project>.git 为 [remote "origin"] ...

阅读全文...

Git 分支管理

Git branch 中蕴含的哲学 Production-ready code 与 developing code 的分离 Do one thing, do it well. 每个分支的目的性明确,只做一件事。 多功能可以并行开发,且新功能与 hot fix 可以同步进行。 简化 branch new-branch & checkout new-branch 操作 $ git checkout -b <new-branch> 应用场景:加入一个临时功能,并在活动结束后去掉 git merge 默认是 fast-forward, 即合并分支后,从 log 中去掉了分支 ...

阅读全文...

将一个文件从 Git 仓库历史中完全删除

背景 无意间将一张非常大的图片(6M)提交到了 Git 仓库中,导致提交到 BitBucket 非常慢 ,所以需要将其从 Git 提交历史中完全删除。 在 BitBucket 被墙的情况下,甚至出现错误 error: RPC failed; result=55, HTTP code = 200 另外一种情况就是, 提交了敏感的信息,例如密码,key 文件等。 解决 git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch app/img/*' --prune-empty --tag-name-fil ...

阅读全文...

git pull 并强制覆盖本地修改

操作 清除本地修改 git reset --hard 拉代码 git pull 参考 Git Pull While Ignoring Local Changes? ...

阅读全文...

git

对远端分支进行回滚 git pull origin master git reset --hard <commit_id> git push origin master --force 参考 git 怎样删除远程仓库的某次错误提交? 版本号控制 当看到 Facebook Messenger 的版本号已经到了 70.0 的时候,我就明白了,版本号自己开心就好。 Bitbucket 拉取代码报错 Permission denied (publickey) 通过诊断发现 $ ssh -vT hg@bitbucket.org OpenSSH_7.2p2 Ubuntu-4, OpenSSL ...

阅读全文...