git工作流真的是一个不错的工作方式,尤其是版本控制和merge方面。但是自己好像在git上遇到的坑也不少了。
寒假的时候,在家里用电脑提交不知道怎么回事就是提交不到github上去。最后在群请教,弄了大约一个多小时才修复成功。最终的原因是因为DNS污染,不过那次学到了很多,最后解决的方法是提交的时候直接用github的IP提交。同事还学到了一下git,ssh错误的常用的分析方法。
不过昨天晚上又在git的问题上栽了个跟头,更准确的说是栽在了bitbucket上,因为准备做的这个项目要用一个私有库,虽然github上学生用户可以免费用两年的私有库,但是感觉有点麻烦,且bitbucket也不错也就用这个了。一切准备OK之后准备push的时候,总是提示:
conq: repository access denied. access via a deployment key is read-only.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
开始以为是key的问题,于是就把key删除之后重新创建,不可以,然后又以为和寒假的情况dns问题,用IP的方式push也是不可以,然后用重新clone最后还是不可以,就这样尝试各种方法。最后又仔细分析了错误提示,自己一直使用的最后两句提示来搜的,于是乎把前两句也复制进来搜索才发现不是git的原因,是bitbucket的原因。在项目下创建的那个key是一个read-only的key是不能够push的,要将pub_key放在你的账号下才可以。最后调完已经十点半了。
顺便总结一下这次所用到的git的技术东西吧。
安装git后配置
1 2 3 |
git config --global user.name "your name" git config --global user.eamil "your eamil" # not mail git config --global -l #查看配置列表 |
生成ssh-key
1 |
ssh-keygen -t rsa -C "XXX@xxX.com" |
调试方法
1 |
ssh -vT git@bitbucket.org |
提交(确保想pull)
1 2 3 |
git add "your files" # or git add ./ git commit -m "commit msg" git push |
重新添加远端地址
1 2 |
git rm remote origin git add remote origin "address" |
我遇到跟你同样的问题 请问“要将pub_key放在你的账号下才可以” 是指在bitbucket账户设置页面ssh key那里增加吗,我尝试把我的key添进去的时候却会提示Someone has already registered this as a deploy key
这是两个不同的key,部署用的key,和你自己平时传代码的不是一个。
git rm remote origin
git add remote origin “address”
这个是在什么环境下? 我用的不对劲,
我做的是
git remote remove origin
git remote add origin XXX
当时应该是在windows下,但是其实都是一样的,只要你的那条可以执行也是一样的,可能git版本区别吧