![](https://img-blog.csdnimg.cn/20190927151117521.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
git
git上面最常用的命令,以及踩过的坑
螺丝钉tina
这个作者很懒,什么都没留下…
展开
-
[git]Could not resolve hostname github.com: Name or service not known
目录背景操作背景在window下wsl安装git,遇到报错Cloning into 'xx'...ssh: Could not resolve hostname github.com: Name or service not knownfatal: Could not read from remote repository.操作使用root 账号给、etc/hosts文件赋修改权限 su root(输入密码) chomd 777 hosts使用ping github.xx原创 2020-12-01 14:30:53 · 1330 阅读 · 0 评论 -
[git]fatal: could not create work tree dir ‘xxx‘: Permission denied
目录背景操作背景在window上面使用wsl,想安装git取clone代码,遇到报错fatal: could not create work tree dir 'xxx': Permission denied操作返回上一层目录,然后赋权限$ cd ../ (回退到当前目录的上一级)$ sudo chmod o+w dirname (dirname为存放代码文件夹的名字)...原创 2020-12-01 11:50:45 · 5049 阅读 · 0 评论 -
[Git]提pull request,遭遇代码冲突
目录背景操作背景A同学做了一个项目,B同学需要添加测试代码,B把本地写好的代码添加到远程后,准备提一个pull request,发现代码冲突了。操作原创 2020-08-05 15:18:34 · 531 阅读 · 0 评论 -
[Git]保持本地和fork的原仓库代码一致
这里写目录标题背景操作背景A同学做了一个项目,B同学需要添加测试代码,但是A不想让B直接操作自己代码。所以B同学fork了A的github仓库,克隆到本地添加,问题来了B怎么使本地仓库和远程库一致。操作fork A同学的项目,在A同学github仓库页面点击fork克隆到本地,B同学把fork的库克隆带本地git clone git@github:B/project添加新的远程仓库地址 git remote -v //查看远程库 git remote add fork g原创 2020-07-10 17:00:24 · 1112 阅读 · 0 评论 -
如何从ubuntu把代码上传到github
背景 在学习docker,用的ubuntu,想将写的code上传上去步骤:安装git sudo apt-get install git生成密钥,一直回车 ssh-keygen -t rsa -C "xxx@xxx"验证ssh -T xxx.github.comssh连接,把rsa_pub复制到github上面,顺便建立个仓库ca...原创 2018-04-26 20:57:29 · 797 阅读 · 0 评论 -
5分钟使用Hexo搭建博客
目录背景操作安装hexo切换主题编辑使用github发布背景sphinx要用rst格式编写,感觉有些麻烦,正好看见用hexo编写博客,直接可以使用md格式,更方便快捷。操作安装hexo全局安装hexo(命令行)$ npm install -g hexo-cli上传到github切换主题编辑使用github发布...原创 2020-03-21 09:36:18 · 277 阅读 · 0 评论 -
[Git]连接两个远程github账号,实现同时更新
实战 本机与github建立2个ssh连接(方法看这) 初始化本地库 与仓库建立连接(2个)(两个仓库要是新建的,空的。不然gitpush会出错) 代码 git initgit remote add origin https://github.com/XXXXX.git//添加第二个地址git remote set-url --add origin h...原创 2019-10-12 12:36:38 · 338 阅读 · 0 评论 -
本地仓库和github仓库连接
背景,复习git操作,本地创建好的文件无法和github仓库连接起来,查了很多资料,发现网上资料缺损 实战 新建文件夹+文件 添加远程仓库 拉取远程仓库代码到本地 将本地文件上传 git push 具体看下面代码 代码 mkdir testcd testgit init touch kkk.txtgit remote add origin git@...原创 2019-08-14 18:25:22 · 614 阅读 · 0 评论 -
放弃本地修改,强制更新(git,github)
###背景本地有修改,但是不想提交,想放弃修改,直接拉取github的最新代码。###操作git fetch --all #下载远程库的最新内容git reset --hard origin/master #把head指向刚刚最新的最新代码###报错...原创 2018-10-24 10:26:52 · 2803 阅读 · 0 评论 -
[git]Not a git repository (or any of the parent directories): .git
想把docker的代码上传到github上面,老是报这个错解决方法:git 仓库的初始化操作git init原创 2018-04-26 20:41:31 · 7526 阅读 · 0 评论 -
一台电脑两个github账号
背景一直用的公司发的电脑,工作时用的公司的github,然后自己有一个私人github,想在一个电脑上面随时切换使用,写个教程方便记录。思路从本地联系到Github远程仓库,可以使用ssh,生成公钥,私钥/公钥对应上就可以连接。 如果我们需要连接两个Github,那么每个Github对应一对私钥/公钥,我们需要两对,然后区分两个账号,push的时候推送到不同的账号就行。设置不同 Host 对应同一原创 2017-11-24 10:18:42 · 1400 阅读 · 0 评论