-
Notifications
You must be signed in to change notification settings - Fork 1
Installing Git
Back ###Introduction
Below are instructions for installing Git. Git is a version control tool that enables users to track revisions and changes in files and coordinate with collaborators. It is often used for software development.
Unlike many applications, such as Microsoft Word, editing and saving files overwrites data. This makes it difficult to track changes without creating different file names, a process that can get messy quickly. Git takes snapshots of files a user wants to track and maintains a history of changes that have occurred. This makes backtracking and checking revisions a simple process, which is especially helpful for large projects with many developers.
Git also functions as a collaborative tool by enabling users to make local copies of a common project and modify them as needed. Users track their own changes and those of others, and Git incorporates tools that enable branching and merging of projects. In other words, users can easily track their own changes and the changes of others.
The following are instructions for installing Git. Note that installing git is not the same as using GitHub. GitHub uses git, but it is a remote server that users can use as a central location for storing data. See the instructions for opening a GitHub account.
###Installation
Open the terminal and enter:
sudo apt-get install git-core
Enter your password, and git will be installed. If you are using another distribution, like Scientific Linux, you may have a different package manager, such as yum. Check online for the appropriate syntax.
![Git installation from the terminal part 2][image2]Once Git is installed, configure it with your username and/or email address. This is preferred in development scenarios so that everyone can identify what modifications were made by which user. GitHub also maps Git user email addresses to GitHub accounts. Note that you do not have to give your real name. Any name will do, as all that is needed is a way to identify who has done what. Technically, Git does not check email address validity, either, but for collaborate work, it is best to provide some address so that people can ask each other questions about changes.
To set up the user names, run:
git config --global user.name "Your name goes here"
git config --global user.email your@address.here
The git part of each command specifies that the script that follows contains Git commands. Git provides a library of functions for executing version control. Rather than have them directly incorporated into system libraries, they are made accessible by preceding the command with git. Therefore, these commands and all other git commands we will use start with git.
The second part, config, is used to configure information, which is stored in a hidden file. The tag --global means that the changes to the user configuration are to affect all user repositories. The details are saved in a hidden file called .gitconfig stored at the base of the user's home directory (~/.gitconfig). Other options allow for different scopes of the effects of configuration changes. --local is the default behavior and specifies that changes be written to hidden file in the working directory called .git/config. You can see what has been set in the config files by running git config --list.
Quick Note: Should you ever need help with a Git command, you can use
git help <commandname>to check the Git documentation in the Terminal. For example, if unsure aboutconfig, rungit help config. Do not enter brackets.
Now, set up an editor for Git to use by default. Editors are used for users to enter comments and messages to explain the changes they make. For this tutorial, we will set Git to use nano.
git config --global core.editor nano
(Optional) Next, set up a default diff tool. When users make changes to files, they can use Git to save a permanent snapshot of them, a process called a "commit". Rather than save every file with each commit, Git only tracks the changes that have taken place. To find those changes, Git uses a diff tool, a tool that compares files and outputs their differences. The tool we will use is vimdiff, but many others are available and less likely to induce nightmares.
git config --global diff.tool vimdiff
git config --global merge.tool vimdiff
Git will select a diff tool by default, but setting it as done above precludes the need to check default behaviors.
![Git configuration part 2][image4]This completes the installation process for Git. To learn how to use Git, click here.