我昨天在GitHub创建了我的第一个存储库.在建立连接时,我使用SSH而不是HTTPS,所以我经历了一个有点痛苦的SSH密钥创建和连接过程.在某些时候我卡住了,连接失败了.我当时想知道如何恢复我开始的过程并开始使用HTTPS连接.令人高兴的是,今天我通过SSH获得了连接,但我想知道能够改变连接类型(SSH与HTTPS)以及是否有办法实现它的价值.
我创建了一个新的存储库,github并希望推送一些文件.所以我像普通的那样初始化存储库并且git add .添加当前目录(这是我的java项目文件夹bin和src里面的文件夹).然后我添加了远程目录:
git remote add https://github.com/username/project.git
Run Code Online (Sandbox Code Playgroud)
然后我做了第一次提交 git commit -m "First Commit"
然后我键入git push -u origin master,我收到此错误:
Counting objects: 63, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (60/60), done.
Writing objects: 100% (62/62), 16.98 KiB, done.
Total 62 (delta 15), reused 0 (delta 0)
error: RPC failed; result=52, HTTP code = 0
fatal: The remote end hung up unexpectedly
fatal: The remote end …Run Code Online (Sandbox Code Playgroud) 我在netbeans IDE中使用git.我想更改我最近提交的提交消息.我这样做了,选中了amend last commit复选框并将其提交到我的本地存储库.当我将此提交推送到我的github仓库时,我收到错误:git remote repository contains commits unmerged into the local branch. open output to see more information.我该如何解决这个问题?我是源控制的新手.我只想用我当前的项目进行非常基本的版本控制.请告诉我如何解决这个问题.
屏幕:

输出消息:
git branch
git remote -v
setting up remote: origin
git submodule status
git push https://github.com/double-whammy/netbeans_affablebean.git refs/heads/master:refs/heads/master
Remote Repository Updates
Branch Update : master
Old Id : id1
New Id : id2
Result : REJECTED_NONFASTFORWARD
Local Repository Updates
Branch Update : origin/master
Old Id : id1
New Id : id2
Result : NOT_ATTEMPTED
==[IDE]== Pushing - …Run Code Online (Sandbox Code Playgroud) 可能重复:
当"git push"到github时出错
我试图将我的新分支(让我们只是调用它new_branch)推送到远程代表.那里还没有这样的分支,但git push origin new_branch:new_branch应该创建它.当我尝试这样做时,这就是我得到的:
error: src refspec new_branch does not match any.
error: failed to push some refs to 'ssh://git@***'
Run Code Online (Sandbox Code Playgroud)
我在SO上挖掘了这样的数百万个问题,但没有一个人同时指出这两个错误,他们只提到了master分支(我不知道它是否有任何区别).
我已经尝试过包括commit,reset并且push在很多配置.到目前为止他们没有工作.我想可能会有一些问题HEAD,因为我不久前搞砸了它.但这是一个猜测,我甚至不知道如何正确检查它,因为GIT 对我来说仍然是一个小小的神秘.
那么 - 我怎样才能摆脱这些错误并将我的本地分支推送到远程存储库?
我在使用GitHub时遇到了麻烦.我正在玩Git的远程存储库.
当我现在尝试对远程目录进行任何更改,即
git remote show origin
Run Code Online (Sandbox Code Playgroud)
要么
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
权限被拒绝(publickey).致命:无法从远程存储库读取.
请确保您具有正确的访问权限并且存储库存在.Ulrichs-MacBook-Pro:coredatatest ulrichheinelt $ git push -u origin master Permission denied(publickey).致命:无法从远程存储库读取.
当我再次使用新的(空的)远程目录时,我会很高兴.或者有办法解决这个错误吗?
这是我昨天开始使用GitHub的第一步......非常感谢提前!
编辑1
我的设置在https://github.com/UlliH/CoreDataTest/settings
...
编辑2
太早开心 :-(
设置SSH和GPG密钥后,错误仍然相同.: - /
编辑3
我认为这是正确的,但仍然是一样的......
我正在与一个团队合作,我们想要使用Git(不使用GitHub,我们有一台私人远程机器).到目前为止我们一直在使用SVN.我们有一台远程机器,就像一个SVN存储库.现在,我们想将这台机器变成Git中央存储库.根据我的阅读,每个人在他们的机器上需要做的是安装Git并使用以下命令添加远程主存储库:
git remote add origin <remote_repo_url>
Run Code Online (Sandbox Code Playgroud)
但那是什么remote_repo_url?我怎么能搞清楚?我们的远程机器有像189.14.666.666这样的IP,在远程机器上我安装了Git并在C:\ MY_GIT_REPOSITORY下创建了一个存储库.我应该在本地机器的URL中放入什么?
我是Git的新手.我搜索了很多,但没有发现与我的情况完全匹配.
我有一个个人的WinForms应用程序,在我的远程仓库中有3个分支(主分支和2个长分支):
master #the common features are here like Core, DAL,...
north #customized for A company (long-running)
razavi #customized for B company (long-running)
Run Code Online (Sandbox Code Playgroud)
在我的办公室电脑上,我worktree为这些north和razavi分支机构添加2 :
$ git worktree list
C:/Source/nis a6fb6e1 [master]
C:/Source/north ebc7670 [north]
C:/Source/razavi eed08a2 [razavi]
Run Code Online (Sandbox Code Playgroud)
到目前为止一切都还可以,我决定从家里开始研究这个项目,但是在我的家用电脑上,当我尝试为这两个分支添加工作树时,它给了我一个错误:
$git worktree add -b north ../north north
fatal: A branch named 'north' already exists.
Run Code Online (Sandbox Code Playgroud)
我删除-b开关以不添加新分支,但它也不起作用.
如何worktree从现有的非本地分支添加远程?
更新(解决方案)
在解决了一段时间之后,我找到了解决问题的方法,实际上,这是一个--checkout错过的开关:
$ git worktree add --checkout ../north north
Run Code Online (Sandbox Code Playgroud)
我也会把它放在答案中.
这可能是非常基本的,但我还无法弄清楚:
我有一个 PHP 项目在两台服务器上运行,我们将其称为Live两台Staging
服务器显然都在运行相同的项目,但有一些更改。
当这个项目到达我手中时,Github 上还没有,所以这就是我现在首先要做的事情。
我设法在 Github 上创建一个新的远程存储库并将Live系统连接到它。
(通过将 Github 存储库添加为 'origin' Live)
git remote add origin https://github.com/path-to-repo/repo.git
因此,Live System 目前位于master分支上并且是最新的,origin/master有 4 次提交的历史记录。
Staging现在我也尝试连接 Github Repo
所以我做了一个
git init
git remote add origin https://github.com/path-to-repo/repo.git
git remote -v
origin https://github.com/path-to-repo/repo.git (fetch)
origin https://github.com/path-to-repo/repo.git (push)
git fetch
Run Code Online (Sandbox Code Playgroud)
现在,当我执行 git status 时,我看到存储库仍处于初始提交状态,并且所有文件和文件夹都列为未跟踪:
Run Code Online (Sandbox Code Playgroud)root@staging-host:/var/www/html# git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what …
我的 Git 帐户有问题。每次执行时git push,我都会收到以下错误:

我发现我正在使用 SSH URL:

我尝试使用以下命令切换回 HTTPS URL:
git config --global url.https://github.com/.insteadOf git://github.com/
git config --global url."https://".insteadOf git://
Run Code Online (Sandbox Code Playgroud)
然而,它似乎并没有改变任何事情:

我尝试了许多我认为是解决方案的选项,例如手动配置配置文件,但没有任何效果。
我从Github分了一个回购.在做git remote -v它显示:
origin https://github.com/myusername/moodle.git (fetch)
origin https://github.com/myusername/moodle.git (push)
upstream https://github.com/moodle/moodle.git (fetch)
upstream https://github.com/moodle/moodle.git (push)
Run Code Online (Sandbox Code Playgroud)
它moodle.git有大约10个分支,但回购只显示其中2个.做git branch -a(显示所有分支)我得到:
MOODLE_24_STABLE// just these two on local..how?
* master//
origin/MOODLE_13_STABLE
origin/MOODLE_14_STABLE
origin/MOODLE_15_STABLE
origin/MOODLE_16_STABLE
origin/MOODLE_17_STABLE
origin/MOODLE_18_STABLE
origin/MOODLE_19_STABLE
origin/MOODLE_20_STABLE
origin/MOODLE_21_STABLE
origin/MOODLE_22_STABLE
origin/MOODLE_23_STABLE
origin/MOODLE_24_STABLE
origin/master
upstream/MOODLE_13_STABLE
upstream/MOODLE_14_STABLE
upstream/MOODLE_15_STABLE
upstream/MOODLE_16_STABLE
upstream/MOODLE_17_STABLE
upstream/MOODLE_18_STABLE
upstream/MOODLE_19_STABLE
upstream/MOODLE_20_STABLE
upstream/MOODLE_21_STABLE
upstream/MOODLE_22_STABLE
upstream/MOODLE_23_STABLE
upstream/MOODLE_24_STABLE
upstream/master
Run Code Online (Sandbox Code Playgroud)
如何在不丢失任何数据或任何违规行为的情况下解决问题?
git ×10
git-remote ×10
github ×5
git-push ×3
git-branch ×2
git-fetch ×1
git-worktree ×1
https ×1
moodle ×1
netbeans ×1
push ×1
repository ×1
ssh ×1