Git - First Time Git Setup: Windows
Git - First Time Git Setup: Windows
Overview
Getting Started
The Command Line
Installing Git
Windows
First-Time Git Setup
Your Identity
Generating a new SSH key
Add an SSH key to GitLab
Getting a Git Repository
Initializing a Repository in an Existing Directory
Cloning an Existing Repository
Updating your local code base with remote origin
Initializing a Git Repository in a Directory
Steps needed on Client configuration to fix git client Error - "SSL certificate problem: unable to get local issuer certificate"
Overview
Git is a powerful and popular system for version control. It is one of the essential tools for collaboration in software development teams. If your
project involves several or more members, you should use Git version control system for managing change and configuration on your project.
Getting Started
THE COMMAND LINE
There are a lot of different ways to use Git. There are the original command-line tools, and there are many graphical user interfaces of varying
capabilities. We will be using Git on the command line. For one, the command line is the only place you can run all Git commands. Most of the
GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also
figure out how to run the GUI version, while the opposite is not necessarily true. Also, while your choice of graphical client is a matter of personal
taste, all users will have the command-line tools installed and available.So we will expect you to know how to open Terminal in Mac or Command
Prompt or Powershell in Windows. If you don’t, you may need to stop and research that quickly so that you can follow us here.
INSTALLING GIT
Windows
You can download from : http://git-scm.com/download/win. This is a self installer file and does not require admin permissions. You have to do it
by yourself.
Your Identity
The first thing you should do when you install Git is to set your user name and email address. This is important because every Git commit uses
this information, and it’s immutably baked into the commits you start creating:
Git uses a username to associate commits with an identity. The Git username is not the same as your GitHub username.
Page 1
Open Git Bash and Run following command & validate :
$ cd ~
$ ssh-keygen -t rsa -C "[email protected]"
//This creates a new ssh key, using the provided email as a label. When
you're prompted to "Enter a file in which to save the key," press Enter.
This accepts the default file location. At the prompt, type a secure
passphrase, press Enter. This accept blank password.
$ cd ~/.ssh
$ ls -la
//you should have these files in the directory: id_rsa and id_rsa.pub
SSH keys allow you to establish a secure connection between your computer and GitLab.
Once you add a key, you cannot edit it, only remove it. In case the paste didn't work, you will have to remove the offending key
and re-add it.
You are now ready to use Git over SSH, instead of Git over HTTP !
Page 2
$ cd /c/user/my_project
$ git init
$ git add <yourfiles comma separated>
$ git commit -m 'initial project version'
$ git push origin <branchName>
Example :
$ git push origin master
If you want to connect to gitlab over HTTPS (HTTP URL instead of SSH), more configuration is required as below, this is optional and
needed only if you want to use HTTPS links for setting up local git repo etc
STEPS NEEDED ON CLIENT CONFIGURATION TO FIX GIT CLIENT ERROR - "SSL CERTIFICATE PROBLEM: UNABLE TO GET LOCAL ISSUER CERTIFICATE"
Download (attached here for reference) and store the Blackstone-Root Certificate at a local location [ Preferrably at - %userprofile% so it
remains untouched ]
Blackstone-Root.crt
Backup the current config (Just in case life wanna take you for a ride ) - cp ~/.gitconfig ~/.gitconfig_backup<date>
Edit the gitconfigure file ( if you are a console lover: vim ~/.gitconfig, else any editor will do too ) and update existing or else paste the
following content at the bottom if http and https is not already configured.
even though we wont be connecting to http, http configuration still needs to be specified to cleanly handle http urls
gitlab will force http redirection to https
[http]
sslCAInfo = <your-location_of_root_cert>/Blackstone-Root.crt
sslVerify = False
[https]
sslCAInfo = <your-location_of_root_cert>/Blackstone-Root.crt
Page 3