# Working with Advanced Git  Commands Part I

Creating a branch in a repo

We shall be looking at how to work with some advanced git commands.    
When collaborating on a project using github, and you want to work on an aspect of the project, say for example, the login page, it is best to create a branch in the repo.  
    
How do you create a branch?
A branch is simply a version of a repo. The project working directory is the repo. Branches are created in the directory. Creating a branch is to enable the independent parts that make up a project to be developed separately and then merged together using through pull request to the project repo ( default directory).  
  
The default directory is the repo that houses the project, called main.
The branch is like a sub directory (a tree) which is created and attached to the main.

So follow these steps to create a branch in a repo
1. open git
2.  If the default root directory is master, switch it to main by running                                
        git branch -m master main
3. Then navigate to 
       cd desktop
4. navigate to the folder containing the files for your new branch by running
        cd folder name
5. Initialize the git by running this command
       git init
6. Run this command to initialize the branching process
       git branch
6. Then create the branch name
for example      
       git branch Login-Page 
7. The branch name will be created. Also run,
       git branch
8. Run this command to see the list of branches
       git branch --list

Note: the current working branch usually carries a
        * sign
9. Run this command to add the new branch to the main
        git branch -a
10. Run this command to switch to the new branch
        git checkout Login-Page
**You would notice that the directory has changed from main to Login-Page
11. To add file to this new branch, run this command
        git add .
12. commit your file
        git commit -m "new commit"
13. On github, copy the remote branch URL and run this command 
        git remote add origin URL

Note: Go to the repo on github, then copy the URL on the address bar 
14. When done, run this command
        git push origin Login-Page 

Voila,
your files has been pushed to the new branch

Please like or comment and share
