I want a similar structure to the below graph.
Say I clone a project from github which has a main
branch.
I then want to create a server
branch at the time which the main
branch had its 2nd commit.
Would I create a branch off of my local branch main
which clone the github main
branch?
So would it look something like this?
git checkout -b main_local server
Then how would I update my main_local branch with server branch and then push the changes to reflect in the github main branch?
To create a branch on a previous commit (2nd commit of your main
-branch), need this command:
# in main-branch
git checkout -b server <sha-of-2nd-commit>
To become the changes from server
branch to your main
branch, execute following command:
# change to main branch, when in server-branch
git checkout main
# merge server branch to main
git merge server
Attention: This can give merge conflicts, if you have in both branches change the same file at the same place (line).
After merging, type following to push the changes from local main
-branch to remote main
-branch:
# in main-branch
git push