Working on two different branches on same repo

59 Views Asked by At

I do have a question. I have an project built in React. One on my friend want to build it for iOS. He's working from a Macos. I already have the repository created on my github account and only main branch. How can we do to create a new branch for his iOS app to work on, independently from my react app and be able to push his work on the same repository from my account?

We tried to create a new branch on his OS and push it but it doesn't work. An error (permission denied) occurs. This is what we did:

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

I mention that he's logged with the account that I already invited as a contribuitor. After all those commands the git push command return an 403 error (permission denied).

2

There are 2 best solutions below

0
user2453676 On

I think you should use one branch with two different folders in the same repo. One folder for the React app, one for iOS.

0
amphetamachine On

What you probably want

How you have it set up (no common files), they might as well be in separate repositories.

You could try branch wrangling or creating unrelated branches (branches with no common ancestor commits), but that takes a little Git know-how. In absence of that, you're better off creating separate repositories.

Another reason to create a separate repo is having it all in ONE repo is prone to errors and gotchas ("this branch MUST NOT be merged into that branch").

I'll suggest using a structure something like:

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

Exactly what you're asking

# 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