使用 git bash 推送到 public 存储库

pushing to public repository using git bash

我知道如何推送到 github(到我自己的),但我想知道如何推送或添加一些东西到其他存储库,例如今天我的一个朋友给我发消息说他为我们的项目创建了一个存储库并发给我 https://github.com/******/****?fbclid=IwAR0tE2DKtuKKzhtqMV-NvS9_YuSkq-abHu7QY2tcESOuFOu1kGT_PxFJR7Y 他让我把我们的项目放到那个存储库中,这怎么可能? 我试过“git push < url >”,它说 'not valid: is this a git repository?'

共享 url 看起来不像存储库的 link。 github 提供了两个选项。 https 和 ssh。

https links 看起来像 https://github.com/jacob-nelson/react-native-reusable-ui-components.git,以 *https* 开头,以 .git[ 结尾=28=]

ssh links 看起来像 git@github.com:jacob-nelson/react-native-reusable-ui-components.git,以 *git@* 开头,以 .git

结尾

毕竟,在您能够将代码推送到给定存储库之前,您的朋友必须将您添加为给定存储库的团队成员并提供必要的权限。

您可以通过多种方式推送到不属于您的 github 存储库。最常见的方式是create a pull request。但是,如果您被所有者添加为协作者并获得许可,您也可以推送到您不是主要所有者的存储库。您可以通过转到存储库并单击顶部的 Settings 然后单击左侧的 Collaborators 来更改协作者。

您可以在本地计算机上的 git 存储库中拥有多个遥控器。例如,您可以像这样为您朋友的存储库添加一个遥控器:

git add remote mybuddy https://github.com/mybuddy/someproject
# Note that there is no ?fbclid=IwAR*** etc

并用

列出它们
git remote -v

那么除了推送到 origin 你也可以推送到 mybuddy

  1. 克隆您的好友存储库:

git clone https://github.com/******/****.git

  1. 创建自己的分支:

git checkout -b new_branch_name

  1. 添加或编辑代码
  2. 添加新文件

git add -A

  1. 提交文件:

`git commit -m "Commit message"

  1. 推送文件:

git push -u origin new_branch_name

  1. 在 github 中从 new_branch_name 向项目的 master 分支发出拉取请求