Git Environment Setup

Setting up name and e-mail address

We need to configure our user name and email address to push the files to GitHub. We can do it as follows, replacing the values with your own name and email.

Open Git Bash in windows or Terminal in Linux and execute following commands.

To create username for git for a particular machine, 

$ git config --global user.name "sree7569"

To set email address for git account,

$ git config --global user.email "sree7569@gmail.com"

To see the list of all the configurations in our git repository,

$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
user.name=sree7569
user.email=sree7569@gmail.com

 

Create Work Space

In Git Bash (Windows), Linux commands will work to create files/directories, changing directories, removing files/directories and we can edit the files using vi editor like in Linux.

Create a directory and add some files in it.

Sree@SreeLaptop MINGW64 ~
$ mkdir MyWorkSpace

Sree@SreeLaptop MINGW64 ~
$ cd MyWorkSpace/

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ pwd
/c/Users/Sree/MyWorkSpace

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ ls

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ touch file{1..5}

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ ls
file1 file2 file3 file4 file5

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ ll
total 0
-rw-r--r-- 1 Sree 197121 0 Nov 10 13:48 file1
-rw-r--r-- 1 Sree 197121 0 Nov 10 13:48 file2
-rw-r--r-- 1 Sree 197121 0 Nov 10 13:48 file3
-rw-r--r-- 1 Sree 197121 0 Nov 10 13:48 file4
-rw-r--r-- 1 Sree 197121 0 Nov 10 13:48 file5

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ rm file5

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ cat file1

Initialize Work Space

To work with git, we need to initialize the the working directory with init command. Then it will create .git (hidden) directory and we can run git commands.

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ git status
fatal: Not a git repository (or any of the parent directories): .git

Sree@SreeLaptop MINGW64 ~/MyWorkSpace
$ git init
Initialized empty Git repository in C:/Users/Sree/MyWorkSpace/.git/

Sree@SreeLaptop MINGW64 ~/MyWorkSpace (master)
$ git status
On branch master

No commits yet

Untracked files:
 (use "git add <file>..." to include in what will be committed)

 file1
 file2
 file3
 file4

nothing added to commit but untracked files present (use "git add" to track)

Sree@SreeLaptop MINGW64 ~/MyWorkSpace (master)
$


 

Advertisements