Advertisement
Tools & Tips

Git Succinctly: Getting Started With Git

by

Installation

Git is available on all major platforms. The instructions below will walk you through installation on Windows, but it's always best to consult the official Git Web site for the most up-to-date information.

Git for Windows is available through the MsysGit package.

  1. Download and execute the most recent version of the installer.
  2. In the setup screen titled "Adjusting your PATH environment," select the option "Use Git Bash only."
  3. In the setup screen titled "Choosing the SSH executable," select "Use OpenSSH."
  4. Finally, select "Checkout Windows-style, commit Unix-style line endings" and press "Next" to begin the installation.

This will install a new program called "Git Bash," which is the command prompt you should use whenever you're working with Git.

Figure 6: Screenshot of Git Bash
Screenshot of Git Bash

Configuration

Git comes with a long list of configuration options covering everything from your name to your favorite merge tool. You can set options with the git config command, or by manually editing a file called .gitconfig in your home directory. Some of the most common options are presented below.

User Info

The first thing you'll want to do with any new Git installation is introduce yourself. Git records this information with your commits, and third-party services like GitHub use it to identify you.

git config --global user.name "John Smith"
git config --global user.email john@example.com

The --global flag records options in ~/.gitconfig, making it the default for all new repositories. Omitting it lets you specify options on a per-repository basis.

Editor

Git's command-line implementation relies on a text editor for most of its input. You can enable Git to use your editor-of-choice with the core.editor option:

git config --global core. editor gvim

Aliases

By default, Git doesn't come with any shortcuts, but you can add your own by aliasing commands. If you're coming from an SVN background, you'll appreciate the following bindings:

git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch

Learn more by running the git help config in your Git Bash prompt.


Initializing Repositories

Git is designed to be as unobtrusive as possible. The only difference between a Git repository and an ordinary project folder is an extra .git directory in the project root (not in every subfolder like SVN). To turn an ordinary project folder into a full-fledged Git repository, run the git init command:

git init <path>

The <path> argument should be a path to the repository (leaving it blank will use the current working directory). Now, you can use all of Git's wonderful version control features.


Cloning Repositories

As an alternative to git init, you can clone an existing Git repository using the following command:

git clone ssh://<user>@<host>/path/to/repo.git

This logs into the <host> machine using SSH and downloads the repo.git project. This is a complete copy, not just a link to the server's repository. You have your own history, working directory, staging area, and branch structure, and no one will see any changes you make until you push them back to a public repository.

This lesson represents a chapter from Git Succinctly, a free eBook from the team at Syncfusion.

Related Posts
  • Code
    Web Development
    Easily Deploy Redis Backed Web Apps With DockerDocker wide retina preview
    Learn how to setup and deploy a Redis powered Python web app using Docker.Read More…
  • Code
    WordPress
    An Introduction To Deploying WordPress with MinaImage400
    As a PHP application, WordPress is usually deployed by a very old method: uploading files via FTP. We have some deployment tools, but they often requires some type of Ruby skill. For example, one popular, powerful tool is Capistrano, but it's also very heavy with many Ruby/Rails related features. I also think that it's little bit tricky to install Capistrano for a PHP developer without any Ruby knowledge. So what options do we have as WordPress developers? In this tutorial, I will introduce you Mina: A small, light tool aims to fast deployment and server automation.Read More…
  • Code
    PHP
    Setting Up a Local Mirror for Composer Packages With SatisComposer retina preview
    Installing all your PHP libraries with Composer is a great way to save time. But larger projects automatically tested and run at each commit to your software version control (SVC) system will take a long time to install all the required packages from the Internet. You want to run your tests as soon as possible through your continuous integration (CI) system so that you have fast feedback and quick reactions on failure. In this tutorial we will set up a local mirror to proxy all your packages required in your project's composer.json file. This will make our CI work much faster, install the packages over the local network or even hosted on the same machine, and make sure we have the specific versions of the packages always available.Read More…
  • Code
    Articles
    Coding With KodingCoding with koding retina preview
    Cloud IDEs have been around for a little while now, and they have been pretty good for things like pair programming, or cases where you want to code consistently no matter where you are. Koding just came out of private beta, and they would like to take this notion a couple steps further, with their "cloud ecosystem". In this article we will take a look at what Koding is, as-well as some of the benefits you can get from using it.Read More…
  • Code
    Tools & Tips
    Setting Up a Mac Dev Machine From Zero to Hero With DotfilesMac dev zero hero preview 400
    Setting up a new machine can often be an exciting prospect. However, as developers, there are a lot of tools we need that don't come as standard. In this post, I'd like to go through some of the techniques I use to help set up my machine quickly, efficiently and with added super powers.Read More…
  • Code
    Tools & Tips
    Git Succinctly: Remote RepositoriesGit succinctly cover 400
    Simply put, a remote repository is one that is not your own. It could be on a central server, another developer's personal computer, or even your file system. As long as you can access it from some kind of network protocol, Git makes it incredibly easy to share contributions with other repositories.Read More…