无法推送到远程Git仓库 [英] can't push to remote Git repo

查看:121
本文介绍了无法推送到远程Git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚通过Github跳入Git,并且正在从svn转移。我创建了一个私人回购,我打算用它来保持我的个人项目在工作和家庭之间同步。在创建远程回购的过程中,工作中的本地文件被推上了。昨晚,我能够将它们拉到我家里的笔记本电脑。



现在我在工作中向repo目录添加了一些新文件。我做了git add filename,其中filename是我的文件。然后我做了git commit -m'我的信息',这似乎工作。
我无法将它们推送到远程。我尝试了'git push personal',但出现错误:

 至git@github.com:geuis / personal.git 
! [被拒绝] master - > master(非快速转发)
错误:未能将一些文件推送到'git@github.com:geuis / personal.git'



当涉及到这个东西时,Svn是非常简单的。我一直在尝试阅读有关Git如何工作的文档,但大部分似乎假设您已经知道基础知识。



对于我的情况,基本知识是什么我需要知道?在Github上进行远程回购,并在工作和家中进行2次单独签出,并将手动同步到远程设备。



我在Mac上。

解决方案

为了能够推送到远程,一般来说,您需要了解远程分支的最新情况。先尝试 git pull ,然后 git push 。



另外,github建议你做 git push -u personal master ,这样头部就可以远程设置了

I just jumped into Git yesterday via Github and am moving away from svn. I created a private repo that I intend to use to keep my personal projects synced between work and home. During the process of creating the remote repo, my local files from work were pushed up. Last night, I was able to pull them down to my laptop at home.

Now I added some new files to the repo directory at work. I did "git add filename" where "filename" is my file. Then I did "git commit -m 'my message'" and that seemed to work. I can't push them to the remote though. I tried 'git push personal' but got an error:

To git@github.com:geuis/personal.git
 ! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:geuis/personal.git'

Svn is really straight forward when it comes to this stuff. I've been trying to read through docs on how Git works, but most of it seems to assume you already know the basics.

For my situation, what are the basics I need to know? Remote repo on Github, and 2 separate checkouts at work and home that will be manually synced to the remote.

I'm on a Mac.

解决方案

To be able to push to the remote, generally speaking, you need to be up to date with the remote branch. Try git pull first, then git push.

Additionally, github recommends you do git push -u personal master so that the head is set remotely

这篇关于无法推送到远程Git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆