gitgithubbranchgit-branchbranching-and-merging

How to create a branch from code available on GitHub, worked on SVN before


I am new to Git and it's so confusing to me :(. I previously worked with SVN before and Git making it so tricky for me.

The master code is available on GitHub. I need to create a branch and update the code for some bugs.

I searched on web and everyone is saying I should have master checkout to my machine and then create a branch. I followed suggested steps but it messed the branch system and now I cannot push code update. I am not sure how this works.

I deleted everything I had created using those steps. Currently I don't have any code on my machine. How can I create a branch from code available in the GitHub web interface?

Edit: I posted a question because on every suggested page there is whole a lot of information and for a first timer it's overwhelming . I accepted the answer and it's perfectly solved the issue.


Solution

  • In general, you need to follow these steps:

    1. Install Git - that's a system-specific point.
    2. If needed, set up your SSH keys to access the remote repository and git credentials - that's a system-specific point too.
    3. Clone the repository using git clone <git_repo_link> (you should be able to find the command in the remote repository).
    4. Checkout to the master branch: git checkout master.
    5. Create and checkout to the new branch out of the current branch (which is master): git checkout -b my-branch-name.
    6. Now you're in the new branch and can make your own changes