TABLE OF CONTENTS
1. Introduction to Git2. Git Installation on Windows5. Git Installation on Max OS X6. Git Installation on Linux7. Undo the last Commit8. Takeaway9. CloudThat 10. FAQs
Introduction to Git
Distributed development allows developers to clone multiple projects’ Git repositories and work on them without worrying about versioning. Git is a version control system that tracks changes in a project directory. Git is an open-source distributed version management system that can handle small to large projects efficiently and quickly. Linus Torvalds was the first to develop it.
Git is used for version control in a large number of commercial and open-source projects.
Git Installation for Windows
Install Git for Windows as a stand-alone program:
Get the latest Git for Windows installation.
The Git Setup wizard will appear on the screen once the installation has begun.
Follow the prompts to complete the installation.
Go to the command prompt, and create a username/email with the following commands.
git config -global user.name “Sonam”
git config -global user.email [email protected]
These details will be part any commitments you make.
Git Installation on Mac OS X
Open a terminal to verify that Git is installed.
git –version1git –versionIf you wish to install the latest version, it is easiest to use the standalone installer.
Get the latest Git for Mac installation.
Follow these steps to install Git.
Now, open the terminal by typing:git-version1git-version
You can set up your username and email with the following commands: Git config.name “Sonam” Git config.email [email protected]
These details will be part any commitments you make.
Git Installation on Linux
Add the following command to a shell:sudo-apt-get updateudo-apt-get installation git12sudo-apt-get updatedudo-apt-get git-get install
Now, check if Git is installed:git-version1git-version
Now create a username with the following commands:git configuration -global users.name “Sonam”.email [email protected] configuration -global users.name “Sonam”.email [email protected]
These details will be part any commitments you make.
Once Git is installed, you can create your own local git repository.
Follow the commands at the terminal or command prompt.
Your mygit folder is now created on your desktop.
Run the Git init command to initialize a Git repository in the root folder.
Create a new file under mygit folder.
Git doesn’t track your files unless you tell it.
Use the git status command to check which files are being followed by Git.
Now tell Git you want Git to track the file you have created.
Use the Git command to add a filename.
It is time for you to make a commitment.
Use git commit-m “Message” command to commit.
You have successfully completed your first commit.
Undo the last commitment:
To undo changes and to revert back to the previous commit, use the revert command.
To undo a published commit
git revert[hash]1git [hash] A hash is a code that uniquely identifies each commit. Run the following command to obtain a hash:
git log1git Log
You can also specify multiple users using.gitconfig
An individual repo can be configured to use a particular user/email address, which overrides the global configuration.
Run from the root of the repo
git config User.name “Your Name Here”git configuration User.email (“Your Email Here”)12git config User.name “Your Name Here”git config User.email (“Your Email Here”) The default user/email is configured in your.gitconfig
git config.global username.name “Your Name Here”git configuration -global User.email [Your Email Here]12git config.global User.name “Your Name Here”git Configure -Global User.email [Your Email Here]There are many other commands that you can use.