top of page
Writer's picturesumathinselvaraj

GitHub

GitHub is cloud based — platform service for version control and collaboration. GitHub helps you and others to work together on project from anywhere. To understand GitHub you need know 2 important principle

· Version

· Git

Version: Version control helps developers track and manage changes to a software project’s code.

Git: Git is a distributed version control system, which means that the entire codebase and history is available on every developer’s computer, which allows for easy branching and merging.

Let understand some essentials terms in Git/GitHub.

1. Repository

2. Staging

3. Commit

4. Pull

5. Push

6. Branch

7. Checkout

8. Conflicts

Repository : A repository is an organized folder. Repository can have files, folders , spreadsheet etc. whichever necessary for the project.

Branch : In GitHub , there is default main branch. Master branch is where all the codes will available. Each teammate creates their own branch and work on their code. At the end of the day they push their code to master

Staging : Adding the files which we are going to push to GitHub.

Commit : Committing is like confirming the added the files

Push : Push is to push the code to GitHub ( remote repository). When you push the code to Master branch , then your code will be visible to other teammates.

Pull : When you pull the from the master branch , then you will be able to see other codes.

Checkout : When you’re moving from one branch to another, we use checkout. That is, we are leaving the current branch and moving to next to branch.

Conflicts : When one teammate make changes in the file which is already in master , we will get conflicts — while you’re pushing it will just update master, but those you have masters already and their trying to push that time merge conflicts arise.

Now let’s see how to create a repository and clone the existing project into remote repository :

Step 1 : Create an account in GITHUB a https://github.com/

Step 2 : Creating a new repository , in the home page , on the left side their will be New button click that.


Step 3: Now give a name to your repository



Step 4 : Select the visibility — Public or Private (public anyone can see the repo , private — you choose who can see your repository).

Step 5 : Now click create repository. Your repository is successfully created .

Once your repository is created — this is how it looks. Now this repository is empty .


Scenario 1 : Teammate 1 , has project in his eclipse workspace. He is cloning the project to remote.

Clone repo into our existing project :

Step 1 : Open command prompt — give cd <file path>

Step 2 : git init ( init means initializing the git repo) — You will be getting Initialized empty project


Step 3: git add — -all ( adding the files for staging). →all means adding all the files . For the selected files git add <file path>

Step 4 : git commit — m “ add message here”

Step 5: git branch -m master ( here am creating a master branch)

Step 6 : git remote add origin < GitHub link> ( for the first clone you need to give the remote link)

Step 7 : git push -u origin master ( we’re pushing the code to the remote origin in master branch)

Our project is successfully cloned . Now you can go to GitHub , refresh your repo — you will see your folders their….

Scenario 2 : Now Teammate 1 feels he don’t want to disturb the master, he is creating a branch so he will work on his branch and push to master …

Step 8 : Creating a branch — git checkout -b <branch name> ( single command to checking out from master or current branch and switched a particular branch . In this case am checking out master and switched to branch name — Branches

Step 9: git status — Gives the status for the branch — which branch your working and is their anything commit or pull

Scenario 3 : New Teammate joins the project , so now he needs to clone the remote project into his eclipse . Lets see how to do that

Step 1 : Open command prompt , go to your work directory

cd < project path> a git clone < GitHub link >

Step 2 : Now you can see your project in your work space.

Step 3: Go to your eclipse a right click on Project Explorer →click import →inside you will find one more import select that


Step 4 : Pop window will be opened asking you to select from where you need to import the project..

In select window → General Existing Projects into Workspace →Next

Step 5: Import projects , now select the root directory of the project

Click Browse →select folder window will be opened →select folder →finish


Step 6 : Project will be successfully imported into your eclipse.

Scenario 4 : Now 2 Teammate will create a branch and starts to work . Once he worked with his code , he will push the code into master. And 1 Teammate will pull the code from the master . Lets see how to do that ..

1Teammate — branch name : Teammate_1

2 Teammate — branch name : Teammate_2

Step 1 : Go to work directory — add your files to staging (adding all the files)

cd < project directory > git add — all

Step 2 : git commit -m “ message “

Step 3 : git push origin Teammate_2 ( now changes has been pushed to his branch)


Lets merge to master

First we need to checkout to master and then only we can merge

Step 4 : git checkout master

Step 5 : git merge Teammate_2


Then Teammate 1 will pull the code from master. Note : Teammate1 will be in his branch

Step 6 : cd < file directory > git pull origin master


Now Teammate 1 is also having all the files and folder which is in master. You can check by git status.

Thanks for reading .. Happy learning!
68 views

Recent Posts

See All
bottom of page