Git Commands With Output Log
Step by step command only Guide where command starts with symbol $
-----------------------------
- git config --global user.name "your username"
- git config --global user.password "your password"
Track file :
This means the file is added to the git repository in your local machine.
Also called added to the stage area.
Untracked File :
Code is still in your local folder not added to git repository
-----------------------------------------------
Commands
---------------------------
checking current working directory
rssan@DESKTOP-QA9A7TD MINGW64 ~
$ pwd
/c/Users/rssan
creating a new directory
rssan@DESKTOP-QA9A7TD MINGW64 ~
$ mkdir test
getting inside that newly created directory
rssan@DESKTOP-QA9A7TD MINGW64 ~
$ cd test
creating a new directory inside for git repository
rssan@DESKTOP-QA9A7TD MINGW64 ~/test
$ mkdir repo
getting inside the newly created repo directory
rssan@DESKTOP-QA9A7TD MINGW64 ~/test
$ cd repo/
Again created a mygitrepo directory inside
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo
$ mkdir mygitrepo
getting inside mygitrepo directory
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo
$ cd mygitrepo
Making mygitrepo directory as git repository using init command
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo
$ git init
Initialized empty Git repository in C:/Users/rssan/test/repo/mygitrepo/.git/
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ ls
Again checking current working directory
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ pwd
/c/Users/rssan/test/repo/mygitrepo
creating a HTML file inside mygitrepo file
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ touch index.html
Creating style.css file inside mygitrepo local folder
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ touch style.css
Now checking local folder vs repository ...how many files are there inside git repository
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
style.css
nothing added to commit but untracked files present (use "git add" to track)
No files are there in git repository . All are in local folder mygitrepo
Lets add index.html to git repository
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git add index.html
>> now lets check the status
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
style.css
> Yah ! new file index.html is added to git repository as per above log or output
>>Let's remove index.html from repository
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git rm --cached index.html
rm 'index.html'
>> checking status
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
index.html
style.css
nothing added to commit but untracked files present (use "git add" to track)
> Nothing added to the repository
>>Now lets add all files to repository using add. command in a single go
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git add .
>Let's check status
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: index.html
new file: style.css
>2 files successfully added...
>>Let's commit the file to git with commit message syntaxed with -m
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git commit -m "file has been commited"
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'rssan@DESKTOP-QA9A7TD.(none)')
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ ^C
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git config --global user.email "you@example.com"
>> Error as not mentioned the email id on which it will be committed .So fixed it
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git config --global user.email "rssandeeprs@gmail.com"
>>Again try and commit with message -m
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git commit -m "file has been commited"
[master (root-commit) d81e2b7] file has been commited
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 index.html
create mode 100644 style.css
>>Commited
>>Git Log
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git log
commit d81e2b78be66f0211dd5ff267e4e572c5c1079df (HEAD -> master)
Author: Sandeep mishra <rssandeeprs@gmail.com>
Date: Wed Oct 28 19:13:20 2020 -0700
file has been committed
> file has been committed
>>Check branches created
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git branch
* master
>>creating new branch userAuth
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git branch userAuth
>>Again checking all branches
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git branch
* master
userAuth
>>Switching between branches using the checkout command
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (master)
$ git checkout userAuth
Switched to branch 'userAuth'
>>creating new files inside the newly created branch userAuth
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (userAuth)
$ touch auth.js
>>Editing preexist file using vim editer
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (userAuth)
$ vim index.html
>I updated the content in index.html
>Doesit have updated ? or not let's check...
>>Again checking git status
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (userAuth)
$ git status
On branch userAuth
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
auth.js
no changes added to commit (use "git add" and/or "git commit -a")
rssan@DESKTOP-QA9A7TD MINGW64 ~/test/repo/mygitrepo (userAuth)
$
Comments
Post a Comment