git 现在本地创建仓库 再 推送到 远程 github 仓库中

今天,需要再本地使用git管理代码,但是当代码创建好的时候,想发布到github上面的私有仓库中,但是没有提前创建远端仓库,所以需要把本地git仓库推送到远端另外一个仓库了,下面进行简要记录,刚刚经过的过程,方便之后再次使用的时候,不会重复劳动:

  • git 设置 git config user.name user.email 
  • 添加 github 远程 公钥
  • git init . 创建本地仓库
  • 创建文件并使用 git add . 进行文件提交 
  • git commit -sam "" 
  • 创建 github.com private repo 
  • git remote add origin [email protected]:repossh链接
  • git remote show origin 查看远端仓库是否添加成功
  • git push --set-upstream origin master 
  • git branch --set-upstream-to=origin/master master 
  • git pull 和远程仓库进行合并 
  • git config --global push.default simple 设置push default 默认约定
    • Since Git 2.0, Git defaults to the more conservative 'simple' behavior, which only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch. 
  • git push
  • git status 
  • git pull 这个时候 你就会发现 远程仓库已经同步成功;整个推送操作成功;

保持更新,更多内容请关注 cnblogs.com/xuyaowen; 

猜你喜欢

转载自www.cnblogs.com/xuyaowen/p/local-git-repo-to-github.html