DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Git Tutorial: Getting Started

Git Tutorial: Getting Started

Veera Sundar user avatar by
Veera Sundar
·
Jun. 16, 11 · Java Zone · Interview
Like (0)
Save
Tweet
8.82K Views

Join the DZone community and get the full member experience.

Join For Free

git logoI was a long time Subversion user then. So, when I got introduced to Git few months back, I was *really* confused. First of all, I couldn’t visualize some of the concepts that Git talked about.

But then, as I started using Git in my day-to-day work, it got much easy to use and understand. Now there isn’t a single day (except some of the weekends!) in which I don’ t use a single Git command. It became an inseparable tool at my work.

So, just thought of writing my learning as a Git tutorial series to help a bit my fellow developers who want to switch over to Git. Let’ start.

Say Hello to Git

First of all, if you are coming from a Subversion/CVS background – mark my words – forget everything you learned about version controlling. Because Git has a completely different approach to version controlling. Lets see how it differs from other systems.

Git is distributed. Which means, when you clone a Git repo, you’ll get a your own copy of that repo to work with in your local machine. In Git, you get your own code base, you make changes, commit as many times as you want without the fear of polluting the central repo and once you are confident push the code to central repository.

Before diving too much further, let’s look at this awesome diagram which explains the Git workflow (thanks to osteele.com, I have a printout of this pasted at my desk).

git workflow

As you can see in the above diagram, in Git, code lives in 4 different places

  • remote repository - think of it as a Github repository or a remote server hosted in your company. As the name suggests, this code base does not live your local machine and You don’t talk with remote repository often. Only when you pull a code initially and pushing the changes when you are done with it.
  • local repository – when you clone a remote Git repo / or create a new repo, the code base is created here in the local repository. All commits you do will come here first. This lives in your local machine.
  • index - one of the most confusing thing you’ll ever hear in Git. This is something like a intermediate place between your working copy of code and your local repository. It’s like a staging area for your code. You use it to stage which files you want to track & commit. In my next post about My Git workflow you’ll see how index is used. This code base too, lives in your local machine.
  • workspace - it’s your working directory where you create/edit/delete your files. This code resides in your local machine.

Hope you get the basic concepts of Git. It is very important to understand it well before you start using Git. In my next post, I’ll be writing about my Git workflow. Till then, feel free to setup your Git environment.

 

From http://veerasundar.com/blog/2011/06/git-tutorial-getting-started/

Git

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Terraform Controller: Cloud Resource Self-Service
  • MongoDB vs. DynamoDB Head-to-Head: Which Should You Choose?
  • SSH Tutorial: Nice and Easy [Video]
  • 3 Best Tools to Implement Kubernetes Observability

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo