Github – Repository Handling

Clone a Repository

Let’s see how to clone a project from a existing repository. Let’s think I am a new contributor for my friend’s project. So I am going to clone that project to my new folder. Open your new folder and right click on it. Then click “Git Bash Here“.(First you have to install git bash. If you don’t know what is Git Bash Click here ) This article is for Repository Handling.


Advertisement



In the command prompt, write “git clone your_repo_url“. you can get your repo url from the repository. See the image below.

get the url from the repository

It will automatically download your repository’s files. That’s it. Now your can open that project.

Pushing files to repository

You already know how to push your file to your repository if you read my previous article. If you don’t know it’s okay. “git push -u origin master” is the command. But you have do somethings before you push. Just think your friend’s repo has many contributors. what happen when they are push their file at the same time. If you have an answer. That’s great. Repository has only final person’s files that is push to the repository. That is why github introduce git branch.

Github – Repository Handling | Check the status and Branching

Just type “git status“. You must do this command after your cloned. You can see what is the branch your are working on it. What is a branch in github?

It’s like a tree. A tree has many branches. In here we can similar a tree to our project. So a project can have many branches. In here we can use a branch to each other. type “git branch“, you can see the all branches in the command prompt.

If you want to create your own branch type “git branch [you_branch_name]“. If you want to switch to another branch and check it out into your working directory, you can use “git checkout” command.

Advertisement



Github – Repository Handling | Git merge

we can use “git merge [branch_name]” to merge. But what is merging? Let’s think my branch is “BuildITMasters_designer”. I did my work in this branch. We have a main branch called “master” and I want to add my work to this branch without changing other’s work. For that we can use this command.