GIT Installation
Creating a new repository
Creating a local copy of existing repository
- GIT can be installed on many platforms like many other versioning tools available.
- We will be installing GIT on Windows 10,Mac OS High Sierra and Linux Centos 6.9 here.
- Windows installation comes with an executable installer which can be used to install git on the platform.
- Depending upon your operating system(32/64 bit) you can download the executable.
- The latest version for 64 bit available is 2.16.2.
- Windows users who use cygwin can install it via commandline or cygwin's setup executable.
- Linux has a GIT package which can be installed depending upon the version.
- OS X users can install either using .dmg image or use Macports or Homebrew for compiling and installing GIT code.
- Git for windows as stated earlier easy to install we just need to execute the GIT setup available at https://git-scm.com/downloads
- For OS X download the dmg image from https://git-scm.com/downloads
- However if you want to work on latest version of GIT you need to download the source code from GitHub and compile the same using Macports or Homebrew.
- To Install in Linux use the following commands
- yum install git
- This will install GIT
- git --version
- This will show GIT version.
- Our name and email both are used to generate hash on SHA-1 that identifies each commit.
- Following commands are needed to set these
- git config --global user.name "YourName".
- git config --global user.email "user@domain.com".
- Commands with --global specify that their configuration values are for every repository we interact with on the machine.
- GIT global configuration file is "~/.gitconfig".We can edit this file directly even instead of using config commands.
- We can also set settings per repository basis by leaving out --global command.These settings are stored in .git/config file.
- Set the GIT user for specific repository
- cd /path/to/repository
- git config user.name "Your Name".
- git config user.email "user@domain.com".
- Changing "colour.ui" to "auto" makes command line interface colorised.
- Turn colours on where ever possible in GIT UI
- git config --global color.ui auto.
- Changing core.editor changes the default GIT editor to our particular editor.
- GIT launches an editor whenever we want to create a commit message, edit patches, and do a few other tasks.
- Configure GIT editor
- git config --global cor.editor /path/to/editor
- Following values are checked in order for editor to be used
- GIT_EDITOR environment variable
- core.editor configuration value
- VISUAL environment variable
- Editor environment variable
- plain vi
Creating a new repository
- Repositories are stored in local file system.
- To create a repository type "git init" in the directory you want to start tracking files.
- This creates a .git directory in your current directory and initializes a .git repository inside.
- You have to initialize the repository only once.
- This will create a private repository for you.
- There are 2 types of repositories in GIT
- private : is created on our local system and where all work is done.
- public : shared with all others.
- This 2 tier system gives you the ability to track local experimental changes.
- And share changes via public repository that are ready for others to work with.
- Once initialized a repository we need to add and commit the files using "git add" and "git commit" respectively, but both of these require an initialized repository first.
- Once initialized we have a working tree that we can interact with.
Creating a local copy of existing repository
- "git clone" command initializes a new repository on our computer fetches entire history from an existing public repository.
- git clone some-repository
- Clone repository to a specific path
- git clone some-repository some-path.
- If we don't require entire history and only need up till a specific revision.We can use -depth parameter to limit how many revisions you fetch.This is called a shallow repository.
- There are a few limitations of this type of repository clone.
- We can't create another clone from it.
- Create a shallow clone with the last fifty commits
- git clone --depth 50 some-repository
- GIT uses SSH by default to transfer changes over the network but it also uses the GIT protocol on port 9418.
I need to clone following repository in folder I just created
It is cloned as follows




Comments
Post a Comment