码迷,mamicode.com
首页 > 其他好文 > 详细

git error

时间:2015-11-05 14:48:37      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

一,今天在上传代码时出错:

$ git push -u origin master
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/freemao/Genotype-corrector.git/info/refs

fatal: HTTP request failed

 

解决办法:

$ git remote set-url origin https://freemao:freemao1234@github.com/freemao/Genotype-corrector.git

之前的url是:https://github.com/freemao/Genotype-corrector.git

相当于添加一下用户名和密码

git remote set-url 相当于是修改了配置文件.git/config 中的url

修改过以后,成功提交。

如果url中不添加密码,只添加用户名,可能会报下面错误:

(gnome-ssh-askpass:52175): Gtk-WARNING **: cannot open display:

 

二,我先修改了一个文件,然后将他重命名,在github上将原来的那个文件给删了。接下来我再push就报错了:

$ git push -u origin master
To https://freemao:freemao1234@github.com/freemao/Genotype-corrector.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://freemao:freemao1234@github.com/freemao/Genotype-corrector.git‘
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the ‘Note about
fast-forwards‘ section of ‘git push --help‘ for details.

解决办法:

先pull一下:

$ git pull -f --all
Fetching origin
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From https://github.com/freemao/Genotype-corrector
e94b6ee..960d781 master -> origin/master
Merge made by recursive.

再push:

$ git push -u origin master

OK了。

正确的改名字的方法:

先mv

然后 git add newname

git commit

git push 

这个时候新文件被push了。但是老文件还在github上

接下来

git rm oldname

git commit

git push 这样就把老名字的文件在github上删除了

 

 

by freemao

FAFU

git error

标签:

原文地址:http://www.cnblogs.com/freemao/p/4939253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!