Working with GitHub

Working with GitHub

Learning GitHub part 2

Β·

2 min read

GitHub is what makes your work make more collaborative and keeps track of it.

if you haven't read my blog on GitHub part 1, I highly recommend you read it first.

Learning GitHub part 1. and if you don't have a GitHub profile please create one.

Done? let's get started with GitHub.

So we will start by creating a new repository, why do we need a repository in GitHub when we have it in our local? the reason is if we want to share our work or want to add anyone to work along on our project we can achieve it through GitHub.

So creating a repo is pretty simple all you need is to go into your GitHub profile there on the top left you can find a green button something like this.

click on that button and that will take you to this page.

here put your project name as the repository name and you choose to put your project as public or private.

Once you create you create your GitHub repo copy the link. and add it to your local with cmd: git remote add the origin url (in place of url you paste your github which you just copied)

here origin is the name of your url.

Once you have connected your local with your github and you want to see the files in your local on your github repo you can directly push them with the command

git push origin master

here master is the branch.

While working on a project you should never push your changes to the main branch. Instead, create a separate branch and merge it later.

In order to create a separate branch you can use this command :

git branch feature

And you can switch the control to that branch using command :

git checkout feature

This way the changes made in the main branch remain in the main and the changes made in the feature branch remains in the feature branch.

now you can merge the branches using the command :

before doing that check out the main branch.

git merge feature

That's it for this blog.

Meet you in the next blog where I will share my experience on contributing to open source projects until then keep learning and goodbye.

Β