git 如何在没有本地分支的情况下从 netbeans 推送到 github

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14942738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:11:47  来源:igfitidea点击:

How to push to github from netbeans without local branch

gitnetbeansgithubrepository

提问by Rayjax

I have received a github project url from a friend of mine who gave me r/w access to his repo. I downloaded the stuff with the "download as zip" button on github, worked on the project, but now when in neatbeans i do right click/remote/push, i enter repo informations, then it asks me to choose a local branch which i don't have because I downloaded manually the files.

我从我的一个朋友那里收到了一个 github 项目 url,他给了我对他的 repo 的 r/w 访问权限。我用 github 上的“下载为 zip”按钮下载了这些东西,在这个项目上工作,但是现在当我在neatbeans 中右键单击/远程/推送,我输入 repo 信息,然后它要求我选择一个本地分支,我没有,因为我手动下载了文件。

So I created a local branch with the same name of the only branch of the project I can see on github, but when I do "push", nothing changes on the repo. My versions simply don't get uploaded.

因此,我创建了一个与我在 github 上可以看到的唯一项目分支同名的本地分支,但是当我执行“推送”时,repo 上没有任何变化。我的版本根本没有上传。

Any clue ? I am new to git so sorry if I ask something which may seem obvious. THanks

任何线索?如果我问一些看起来很明显的问题,我是 git 的新手,所以很抱歉。谢谢

回答by OMGtechy

I have had this problem myself.

我自己也遇到过这个问题。

The solution I found was to make changes to the code, commit the changes and then push.

我找到的解决方案是对代码进行更改,提交更改,然后推送。

In short:

简而言之:

  1. Make changes to the code
  2. Commit changes (under team menu)
  3. Push changes (under team->remote)
  1. 对代码进行更改
  2. 提交更改(在团队菜单下)
  3. 推送更改(在团队-> 远程下)

Hope this helps!

希望这可以帮助!

回答by mr.VVoo

You can try the following:

您可以尝试以下操作:

  1. Backup your changes.
  2. (assuming git is installed correctly) checkout the project from GitHub using git clone <url>(now you should be on a master branch. if there is only one branch that doesn't matter, if there are other branches be sure to use the right one with git checkout)
  3. Then try to copy your changes (files from backup) on top of the files retrieved by git clone.
  4. within the repo's root directory run git statusand check if there are files need to be staged to the index (git add)
  5. if everything is staged to the index run git commit -a -m "some message"
  6. finally run git push
  1. 备份您的更改。
  2. (假设 git 安装正确)使用从 GitHub 签出项目git clone <url>(现在你应该在主分支上。如果只有一个分支无关紧要,如果有其他分支,请确保使用正确的分支git checkout
  3. 然后尝试将您的更改(备份中的文件)复制到git clone.
  4. 在 repo 的根目录中运行git status并检查是否有文件需要暂存到索引( git add)
  5. 如果一切都上演到索引运行 git commit -a -m "some message"
  6. 终于跑了 git push

Using GitHub you maybe require a ssh key or use the HTTP connection. BUTthis is of course a bad solution because you treat the idea of SCM with contempt. In the future you should first connect to a repository, make your changes commit and push them. Only then you are able to do fine-grained commits and revert them if something was wrong. Commiting a large set of changes is not the right way!

使用 GitHub,您可能需要 ssh 密钥或使用 HTTP 连接。 当然这是一个坏的解决方案,因为你把SCM带有轻蔑的想法。将来,您应该首先连接到存储库,提交更改并推送它们。只有这样,您才能进行细粒度的提交,并在出现问题时还原它们。提交大量更改不是正确的方法!