GIT ~ Lets Take Coordination In To Picture

What is Git  ?   What it is used for?

Imagine You and your team mate can work on a same project at a same time without disturbing each other.

Now the question comes :  Is this possible?

Yes it is! Git allows two or more people to work on a same project ,even at a same time without interfering in to each others works and still get updated about any changes in the project.

Git is used by many team leaders to get effective execution of their project.

You can download git from : https://git-scm.com/download/win

Now how does it work.Suppose there is a team of 3 people and a team leader assign Member 1 – A and Member 2-B a single project which involve their different inputs.

Team member will keep the folder “PROJECT” which contain all the project details in a repository  which is kept in Google Cloud.A repository is simply a place where the history of your work is stored.

But how can we judge whether for that folder we can initialize git.

For that first the team leader will give to the access of that repository by adding you and then you can download the folder .

Next Step involves opening that folder ,if you find a “Git” file inside that folder it means you can initialize git for that folder.

images (1)

Now lets understand the whole  path:

STEP 1: Download the “PROJECT” folder from repository at Google Cloud.

Step 2 : Save it on your Desktop and perform your Tasks

Step 3: Next step is to submit your work .This again require few steps:

  • Master (original data set without any changes present in origin). You make a copy of it that will be Master(but local one)and from this locally present Master You make another copy called Branch 1 and do your task in Branch one without making any change in Master(both local and at git hub). Member 2 will work in second copy of Master called Branch 2 (Second copy from local master as  Member 2 will also locally download Master in its desktop)without disturbing Master and Branch 1.

remotes.png

  • Suppose A completes its task and stage  file that is Branch 1,Stage here means the file is ready to commit so that A can push it to the cloud that can be reviewed by the team leader .If  Team Leader approves the task by A then the branch will be live and the Master at cloud will get updated with A’s work.

NOTE: There is Master file in repository at cloud which will be updated by team leader only. Team Members  first get an access of that repository and download Master file and save it in their desktop.

images (2)

  • It is important to note that here order of the delivery of the task matters. A has already done its task and Master at the cloud is updated. How will B will get to know about this update ? For this B type git checkout master to know the updates. Here git will tell B about updated Master at cloud. B task is to now pull new master from cloud and merge B’s work with new master which require few steps:
# To get update about any change in original Master

git checkout master

# To get the updated master locally.

git pull origin master

#To get yourself switched to Branch 2

git checkout branch2

# Now merge master to branch 2

git merge master

# Push you work with updated Master to cloud for review

git push origin branch 2

Now take some adjustments :

Start with making an account at github and get an access of repository. Terminal prompt below is currently in a directory named “PROJECT”.

Secondly initialize a Git repository

# Initialize a Git repository

git init

# To make changes in “PROJECT”

git add PROJECT.txt

# To check status

git status

OUTPUT: On branch master

#

# Initial commit

#

# Changes to be committed:

#   (use “git rm –cached <file>…” to unstage)

#

#             new file:   PROJECT.txt

 

To Create a Branch:Copy of Master

#  Create a Branch for Task 1

git branch Task 1

 

With git branch you’ll see two local branches: a main branch named master and your new branch named clean_up.

You can switch branches using the git checkout Task 1 command.

#  Switch To branches

git checkout Task 1

 

As A do his task now he has to commit its Branch so that it can be further pushed to git hub origin.

# run the commit command with a message describing what we’ve changed

 git commit -m “Task 1 completed”

In order to know the history or any change that has been made we use log command.

# Check changes

git log

OUTPUT: 

commit b652edfd888cd3d5e7fcb857d0dabc5a0fcb5e28
Author: Try Git <try_git@github.com>
Date: Sat Oct 10 08:30:00 2020 -0500 Added Task 1 completed
 

 Push command tells Git to push our local changes to our origin repo (on GitHub).

# push local Branch 1

git push -u origin Branch 1

NOTE: The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.

Get yourself updated with new master and pull it from cloud(For Team Member B).

# Get the updated master from Github

git pull origin master

If B has to look at what is different from our last commit .

# Difference from our last commit 

 git diff HEAD

To see the changes B just staged

# To see the changes you lastly staged

git diff –staged

To undo the lastly staged file we first have to reset stage are.

#  unstage files

git reset <lastly staged file>.txt

Files can be changed back to how they were at the last commit.

#  Get back to the file before last commit

git checkout – PROJECT.txt

Further steps for Team Member B

 

#To get yourself switched to Branch 2

git checkout Task 2

# Now merge master to branch 2

git merge master

# Push you work with updated Master to cloud for review

git push origin Task 2

Here Team Leader Gets the work of Both A and B ,without A & B disturbing each other.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s