Home > Blockchain >  What is the proper way to use branches in Github?
What is the proper way to use branches in Github?

Time:01-16

I've had trouble in the past before with my "index.html" page (labelled as such) not being the first page shown when you type in my domain. With the way I'm currently doing it in Github, all my pages (only three) are all located on the 'main branch'. Should I put my index page on the main branch alone? And create (a) separate branch(es) for my other pages?

The website is nothing but html and css. very very basic stuff.

Are there any other common reasons to explain the index page not being the default homepage?

as you can tell i'm super new (and self-taught) to any kind of coding at all, and any help on this would be super appreciated.

CodePudding user response:

When working on a project, branching enables you to work on different parts of a project without impacting the main or master branch.

E.g - I have three pages to work on for a simple html project: index.html, about.html and contact.html

To work on index.html, I will create a branch with a name that is descriptive of the feature I want to work on.

When I am done with that feature on the new branch, then I can merge to the main branch

git status - To see branch details and commit status

git branch index-page - Creates a new branch called index-page

git checkout index-page - Switches to the new branch index-page

Make you changes to index.html, when done commit

git add . - Stage new changes

git commit -m "Your commit message" - Commit changes

git checkout main - Switch to main if this is your main branch

git merge index-page - Merge changes from index-page into main

CodePudding user response:

TL;DR: you'll use branches in a way that suits you. They don't really mean anything, so you're free to use them however you want.

Long

You're mixing up several things here, although to be fair, (a) it's complicated and (b) GitHub do you no favors here because they add even more complexity atop this already-complicated thing.

  • Git is a Version Control System. Version control systems (VCSes) have a vast (and somewhat boring) history; Git's flavor of VCS is distributed, or a DVCS, in which each repository can be replicated as many times as you like. Some DVCSes have a master/slave or single-source-of-truth setup ("SSOT"): there's one "real" version and a bunch of copies. Git does not use this model: every version is its own king or sovereign entity and all the replicas are inferior clones. This makes life interesting, in that your clone on your computer thinks the GitHub clone is inferior, while the GitHub clone on their systems think your computer is inferior.

  •  Tags:  
  • Related