我是 git 新手。我正在为 git 中的一个开源项目做出贡献。我 fork 了它并创建了一个分支。它是一个android项目。然后我克隆它以创建本地副本并将其保存在文件夹中。我在 android studio 中打开它,进行了所需的更改。然后我执行了以下操作:
git add <the file name where i made changes>
git commit -m <message>
此时我仍然对更改在哪里提交感到困惑?我假设它位于保存在我的计算机中的本地副本中。然后我尝试 push 它,它给了我错误:
git push upstream master
Username for 'https://github.com': Midhun07
Password for 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d19cb8b5b9a4bfe1e691b6b8a5b9a4b3ffb2bebc" rel="noreferrer noopener nofollow">[email protected]</a>':
remote: Permission to opendatakit/collect.git denied to Midhun07.
fatal: unable to access 'https://github.com/opendatakit/collect.git/': The requested URL returned error: 403
但是这里opendatakit/collect.git
是 git 试图 push 更改的地方。但我想将更改推送到我的 master
而不是upstream/master
。但是当我尝试做git push master
时它给了我以下错误。
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.
我的 master 分支与上游/master 相比还落后 9 次提交。我很困惑。请指导我。
最佳答案
upstream
是您派生的原始项目,
https://github.com/opendatakit/collect 。
只有项目的维护者才能 push 这一点。
如果您想将本地更改推送到 GitHub,
然后推到你的 fork 上,
https://github.com/Midhun07/collect 。
它应该被称为origin
,
不是上游
。因此,将命令更改为:
git push origin master
At this point I am still confused as to where are the changes committed?
到您的本地 Git 存储库。 如果您不清楚这一点,那么您需要learn更多的 Git。
I also one another problem of my master branch being behind by 9 commits as compared to upstream/master. I' am all confused. please guide me.
这意味着原始项目已经演变: 自上次与它同步(派生)以来,其他人已经添加了 9 个提交。 如果您想在本地克隆中获取这些提交, 你可以 rebase :
git fetch upstream master
git rebase upstream/master
小心,可能会发生冲突。 您可以在 Git book 中阅读有关 rebase 和解决冲突的更多信息。 .
关于git - 无法将提交推送到 git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42731586/