git 在同一个repo上的两个不同分支上工作

zf9nrax1  于 2024-01-04  发布在  Git
关注(0)|答案(2)|浏览(149)

我确实有一个问题。我有一个在React中构建的项目。我的一个朋友想为iOS构建它。他在Macos上工作。我已经在我的github帐户上创建了仓库,只有主分支。我们如何为他的iOS应用创建一个新的分支,独立于我的react应用,并能够从我的帐户将他的工作推到同一仓库上?
我们尝试在他的操作系统上创建一个新的分支并推送它,但它不起作用。发生错误(权限被拒绝)。这是我们所做的:

git clone repo-url
git checkout -b iOS
rm -rf *
git add .
git commit -m "message"
git push -u origin iOS

字符串
我提到他使用我已经邀请的贡献者账号登录,在所有这些命令之后,git push命令返回一个403错误(权限被拒绝)。

ux6nzvsh

ux6nzvsh1#

你可能想要的
你如何设置它(没有公共文件),它们也可能在单独的存储库中。
你可以尝试分支管理或创建不相关的分支(没有共同祖先提交的分支),但这需要一点Git专业知识。如果没有这些知识,你最好创建单独的仓库。
创建一个单独的repo的另一个原因是将所有的repo都放在一个repo中容易出现错误和陷阱(“这个分支不能合并到那个分支中”)。
我建议使用类似这样的结构:

https://codeberg.org/ourapp/ourapp-server - app server files
https://codeberg.org/ourapp/ourapp-ios    - iOS frontend
https://codeberg.org/ourapp/ourapp-react  - web frontend written in React

字符串
正是你所要求的

# Create a new unrelated branch with no history
git checkout --orphan=ios
# Remove files from old branch from staging area (does not delete files)
git reset .
# Remove untracked files (deletes files, but you can get them back by switching branches)
git clean -xdf
# Tell remote about our new branch
git push -u origin ios

gcxthw6b

gcxthw6b2#

我认为你应该使用一个分支,在同一个仓库中有两个不同的文件夹。一个文件夹用于React应用程序,一个用于iOS。

相关问题