GitBash breakdown for beginners! Use git the way you would need to in a company position!
Tags: beginners, git, github, career
Published: 2020-04-24 20:27:33

*If you like this article, chances are you'd like what I tweet as well. If you are curious, have a look at my [Twitter](www.twitter.com/DThompsonDev) profile. Or check out my podcast! "Commit Your Code!" Where we interview and talk to some phenomenal developers and motivate you to stay on the coding journey!* 

The last thread was about uploading a project to github using a simple method. But in any company you work you are going to need to use git or terminal. 
Have git bash installed then follow.

First go to github & press New.
Now we need a repository name. A repository is the space we are saving our code in. You can add a description to explain what is in this space, so if you come back after a few months you can remember what is in there.

Now lets go ahead and create the repository!

![repository menu](https://dev-to-uploads.s3.amazonaws.com/i/4ad1rj2obu63hh2wvgwj.png)

Copy the URL in the box. And now go to the folder you have your project in.

![Copy the URL](https://dev-to-uploads.s3.amazonaws.com/i/q53p9r2g96t1p57vlk19.png)

Navigate to the folder you have the project in. I lead a group called GDG Memphis, so that is what I named this folder.

Right click and you will see the option Git Bash here. Press it. If you do not see that, go to git bash and navigate to your folder. I will show you how.

![Folder](https://dev-to-uploads.s3.amazonaws.com/i/2lctmbasbsuylgaom5oq.png)

You can type cd <folder name> which stands for change directory and this will allow you to go into another folder. You can go 1 at a time or a way to do it faster would be

cd coding/GDGMemphis/gdgmemphis 

This will give the same result as what you see below. Either way will work.

![Git bash cd](https://dev-to-uploads.s3.amazonaws.com/i/ng4ebhx4nv9dkcy9rxlz.png)

So we need to initialize the folder. We will do that by using 

git init

This is making a .git folder and will be necessary so we can push the contents of this folder. After the init I used git status to see what the status is of the files in this folder.

![git init](https://dev-to-uploads.s3.amazonaws.com/i/1l6lqyb685iyrle07hvd.png)

Here i added our files. Notice the red file names are now green? This shows the files that we have added so that we can commit them.

to add files just do 
git add <file name>
OR! 
git add .

The period means add everything in this folder.

![git add](https://dev-to-uploads.s3.amazonaws.com/i/m7tpt1hft6h2kyza5amj.png)

Now we need to COMMIT the files. Committing means we want these files to be sent to our github repository! To commit we'll use

git commit -m "our message"

ALWAYS write a good commit message. this text will be displayed next to the file name. Professional developers PRAISE detailed messages! Definitely do them.

![commit](https://dev-to-uploads.s3.amazonaws.com/i/crr4l9zy16nhn5qpeobm.png)

Now here is where we add the URL of where we will send our COMMIT or our Files!
so we will use

git remote add origin https://github.com/<your git hub name>/<your repository>

Remember that URL we copied above from the Third image? Time to use that bad boy and paste it in!

![remote](https://dev-to-uploads.s3.amazonaws.com/i/h45jn0yyqvvqspw8k7y9.png)

You can't use ctrl + v to paste. you have to right click and paste or use CTRL + Shift + insert! Now you know why we have an insert key on our keyboard! lol After that type

git push -u master origin

The master branch is the main branch.

![push](https://dev-to-uploads.s3.amazonaws.com/i/1d9hwx7p6s0mfu79cs9f.png)

When you work in a company, you will be expected to work on your OWN branch. after the code is reviewed and tested, then you will MERGE that branch to the master! So how can we do that? Super easy! 

![branch](https://dev-to-uploads.s3.amazonaws.com/i/ff1j04x1rplkelp6rfw3.png)
Notice the green text on the right? Shows which branch we are on!

A working branch is great and will prevent you from destroying the original code by accident! GET USED TO THIS! Vital in any business setting!

git branch <name> creates the branch
git checkout switches you to that new branch!

You have made it the whole way! This was a lot! I WISH I spent more time learning git before getting hired and not knowing how to navigate branches!

You made it the whole way and you are incredible!

![Proud of you](https://dev-to-uploads.s3.amazonaws.com/i/yomlvbf484kzk3ixej1u.png)

Follow me on [Twitter!](www.twitter.com/DThompsonDev)