-1

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.

Jyo the Whiff
  • 829
  • 9
  • 23
  • 3
    I respectfully suggest reading the [Git Basics chapter](https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control) of the Git book. – knittl Nov 20 '21 at 15:24
  • I did read it, I have worked on Microsoft VCS and SVN before so read wasn't that helpful. In SVN many things happen default when you checkout(cloning, creating branch and checkout), in git it's all manual, that's why I was confused. Thanks for the suggestion. – Jyo the Whiff Nov 23 '22 at 08:04

2 Answers2

2

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 :x
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Max
  • 1,996
  • 1
  • 10
  • 16
0

To create a branch directly on GitHub, follow the instructions in Creating and deleting branches within your repository

If you need to modify code, it is better to do it in your own computer, for which you would need to use Git.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
daniel
  • 76
  • 3