git使用中遇到的问题

git使用中遇到的问题:1.版本回退后推送;2.解决每次push输入密码问题;

  1. 当在本地版本回退时,在上传remote时,会出现:
Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@github.com:519ebayproject/519ebayproject.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:519ebayproject/519ebayproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这时应该强行推送:参考网页

git push -f origin <branch>
  1. 在github.com上 建立了一个小项目,可是在每次push的时候,都要输入用户名和密码,很是麻烦
    原因是使用了https方式 push
    在termail里边 输入
git remote -v 

可以看到形如一下的返回结果

origin https://github.com/username/project.git (fetch)
origin https://github.com/username/project.git (push)

下面把它换成ssh方式的。

a. git remote rm origin
b. git remote add origin git@github.com:username/project.git
c. git push origin 

Click the link below to go back to index:

Go back