使用Github遇到的问题及解决办法

时间:2023-03-09 19:41:13
使用Github遇到的问题及解决办法

问题一:

当push代码上去仓库时,出现

! [rejected]        master -> master (fetch first) error: failed to push some refs to 'https://github.com/Jierism/MyLocations.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by 。。。

解决:

 git push -f
git pull
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git pull

详细参考:http://blog.csdn.net/chain2012/article/details/7476493

问题二:

push代码,插入注释git commit -m "注释语句"时,出现

On branch master Your branch is ahead of 'origin/master' by 2 commits.   (use "git push" to publish your local commits) nothing to commit, working directory clean。。。

解决:

 git pull --rebase

再继续push

问题三:

push代码,输入git remote add origin git@github.com:djqiang(github帐号名)/gitdemo(项目名).git,出现

fatal: remote origin already exists

解决:

 git remote rm origin
接着再输入一次地址就OK