Git & Github: 4 hacks to learn to kickass with git & github (Beginner’s Guide).
Tags: Github, Git, Beginners Guide, Programming

Here are the hacks

Hack 4: Branching

You may ask :

What does branching entail?

Why would I want to use branching on github?

Ever been in a situation where you were given an app to work on and you used github, pushed your into the repo and ended up discovering your code modified the previously done work which was not to be changed?

Branching solves that problem for you.

First, you have to create a branch .

Creating and working with a branch

Let’s say you are working on the user authentication functionality of an app and the name of the file is login.js.

*You would want to work on a different branch.

You can name your branch login.

Here is the code to be used on your git bash.

git branch login

This code is to create the branch.

*Switch to that branch (login) on your git bash instead of using the master branch

Type:

git checkout login

*This puts you in the login branch and ready to code.

*Add and push your code into the login branch to avoid complications.

Hack 3: Merging

This helps when the team is done with the project and want to merge all the code into the master branch.

So we have to be in the master branch to do this.

So type:

git checkout master

This switches us to the master branch.

Now we can merge the user authentication functionality in the login branch with the master branch using this code.

git merge login

Remember!

This is to be done in the branch where we want to merge them .

In this case, it is the master branch.

Hack 2:Pulling down the code.

If you want to remove your code from the repo, you can just run this code in your git bash

git pull

This pulls all the code off the repo.

Be cautious of how you use this code because if used where you are not supposed to use it, it would most likely be catastrophic if there is no replacement…… You know what I mean.

Hack 1: Cloning

*To clone a repo, you have to click on clone or download

*Then a dialog box appears.

Dialog box

*You can download it as a zip file if you want download the code.

*But we are talking about cloning.

Copy the link provided in that dialog box and go to the git bash of an empty folder.

On your git bash, type this code:

git clone ' provided link'

For example:

This code pulls and clones the entire repo.

Now you have the entire app at your disposal.

You can clone anybody's project or code as long as the repository is public.

In conclusion,

git branch = to have branches in your code repo

git pull = to pull from the particular repo this code is run

git merge = merge branched code

git clone = Clone a repo into a new directory.

Thank you guys for your time!

SMASH the clap button if this has brought a lot of value to you and if

you enjoyed this content.

It would help the blog to grow and it also keeps me going.

If you are finding value there is a high chance one other person is finding value too, so if you hit that clap button, it makes sure to go to that person and that would be amazing.

Please make sure to follow me to get more of these value packed contents.

Thank you guys for your time and as always i would see you in the next article!

Until next time guys !

Peace y’all!

Agbejule Kehinde Favour.