DEV Community

Samejima
Samejima

Posted on

How to use Github basics

Here is how you fork then clone then use github with a friend or more!

Command line vs desktop app

they both achieve the same thing so I am going to show you both

Step 1 - Fork your repo

find the repo you want to contribute to and click the fork button in the top right of the screen

Image description

there is a prompt to create that fork and you should absolutely click that big green button on the next page

after you do that you now want to click "code" on your forked webpage and then copy the url that is inside there

Image description

Desktop App

Step 2 - clone your repo

click "file" then "clone repository"

Image description

after that a context menu will appear, you will then paste your copied url in that first input area and select a place to have your clone saved, this is important, you should pick somewhere you want this repo saved.

Image description

and you are pretty much done after doing this, another pop up will appear and you should answer accordingly. If you plan on contributing to this repo then you should select "contribute to the parent project"

Step 3 - create your branch

so if you want to make changes and contribute to the repo you need to create your own feature branch, then push to your feature branch and create a pull request(or PR)

to do this in the desktop app you select the "Branch" tab, select new branch and name your branch. These names are public and should be a small description on what you want to accomplish. example "add-run"(there are no spaces in these so you use dashs instead)

Image description

Image description

after you complete that you will have your own feature branch

Step 4 - add(push) to your branch

after you made the changes you wanted to make, you click the Repository tab then click "push" and your branch will show the changes

Image description

Step 5 - pull request

this is simple too, you click the Branch tab then click "create pull request", it will take you to a web page on github and you can fill out the information as stated.

what this does is show the other people on the project that you have a branch with changes you want to make to the main branch. This code will have to be first reviewed by the maintainer of the project and if they like it, it will be merged if not then you get to try again or make some changes!

Image description

Command Line

Step 2 - Clone your repo

for this its simple, you want to open your command line or terminal

select a place where you want this copy to exist, and paste the following

git clone -insert url here-
Enter fullscreen mode Exit fullscreen mode

the rest will happen on its own

Step 3 - create your branch

if you want to make changes and contribute to the repo you need to create your own feature branch, then push to your feature branch and create a pull request(or PR)

go to your terminal or command line and add this

git branch - your branch name -
Enter fullscreen mode Exit fullscreen mode

Step 4 - add(push) to your branch

after you made the changes you wanted to make, you go to your terminal or command line and you post these in order

the "." is shorthand for ALL but you can select specific files you want to add

you then commit those changes along with a short message describing the changes

and finally you push the code.

This can also be done in the UI of VS code

git add .
git commit -m -Your commit message here-
git push origin - your branch name -
Enter fullscreen mode Exit fullscreen mode

Step 5 - pull request

for this step you want to go to your github account after you pushed your code to your branch, then you will see a a big green button that says compare & pull request you click that button then you fill out the information as requested.

Image description

Top comments (0)