zoukankan      html  css  js  c++  java
  • [git] git push问题 解决 Updates were rejected because the tip of your current branch is behind 和每次输入用户名和密码

    问题1: 当尝试push到github时 git push -u origin master 出现

    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.

    原因 :远程仓库与本地有不同,需要合并(比如:在github创建仓库时初始化过了,你现在把一个本地仓库与它关联并想push,那先要和原先的github仓库合并)

    解决方法

    命令(假设你的远程库名字是origin)

    git pull origin master
    

    使用git pull将最新的更改从远程存储库拉到本地存储库。

    问题2: git push 每次都需要输入用户名和密码

    原因 : 采用的是 https 方式提交代码,创建版本库时用的

    git remote add origin https://github.com/user/repo.git

    解决方法 :如果采用的是 ssh 方式只需要在版本库中添加用户的 sha 的key就可以实现提交时无需输入用户名和密码。

    步骤1:改用下面的创建版本库方法:

    git remote add origin git@github.com:(用户名)/版本库名 
    

    例如:

    git remote add origin git@github.com:michaelliao/learngit.git

    步骤2: 之后需要创建SSH Key(如果之前在github中添加过了,就可以忽略这一步),参考 廖雪峰老师

    步骤3: 提交代码,已经不用登录了

    git push -u origin master

  • 相关阅读:
    php 内置的 webserver 研究。
    php 系列
    git 以及 github 使用系列
    中午和同事聊天,了解的一点网络方面的东西。
    javascript中0.01*2324=23.240000000000002 ?
    javascript的 replace() 方法的使用讲解
    PHP中的ORM
    javascript 函数 add(1)(2)(3)(4)实现无限极累加 —— 一步一步原理解析
    animate.css
    面向对象编程
  • 原文地址:https://www.cnblogs.com/conver/p/12232038.html
Copyright © 2011-2022 走看看