Wednesday, July 24, 2019

Git Crash Course

GITUB:
IT is version control system(VCS) and Source Control Mngmt(SCM).
1,Repositories
2.Version
3,Artifact
4,Comparision
5,Collaboration
6,Accountability

Gitub Birth-2005
Git founder->Linus Torvalds

3 main states in GIT:
Modified
Staged
Commited

3 section:
Working directory ->It is a root directory
Staging Area: Also called index
Commit ARea:

git version


Configuring author and email
# home directory
$ pwd                                                          
$ mkdir git-fast          
$ cd git-fast
$ pwd  
$ git config --global --list   
$ git config --global user.name "Bibhash Roy"
$ git config --global --list
$ git config --global user.email "bibhash@whitepeaksoft.com"
$ git config --global --list
# vi is the editor, ~ is the home directory
$ vi ~/.gitconfig                                              
$ cat .gitconfig


Initializing an empty repository
$ pwd
$ mkdir myRepoFromScratch
$ cd myRepoFromScratch
$ pwd       
 
# notice the creation of .git directory                      
$ git init 
                     
# "ls -al" command lists all objects, including hidden                                           
$ ls -al
    
# without using any editor                                                               
$ echo "this is my first file in empty repository" >> firstFileUsingEcho.txt   
$ ls
$ cat firstFileUsingEcho.txt
 # create the file and enter some contents
$ vi  secondFileUsingVI.txt                                      
$ ls
$ cat secondFileUsingVI.txt


Existing unversioned project to repository
$ pwd
 # copy the downloaded file
$ cp /f/Bibhash/Downloads/initializr-verekia-4.0.zip .
# unzipping will create a folder called "initilizr"   
$ unzip initializr-verekia-4.0.zip                                      
$ ls -al
# remove copied file
$ rm initializr-verekia-4.0.zip
# rename directory                                        
$ mv initializr/ myRepoFromExistingSource  
            
# now we need to add source control to the unversioned repo "myRepoFromExistingSource"
$ cd myRepoFromExistingSource
       
# Initialized existing source                      
$ git init          
# .git folder can be seen with ls -al                                                             
$ ls -al
                                                               
Command Summary - configuration & repository creation
# Typically, you’ll want to use the --global flag to set configuration options for the current user.
# Define the author name to be used for all commits by the current user.
$ git config --global user.name     
# Define the author email to be used for all commits by the current user.
$ git config --global user.email    
# For listing all the global configuration at user level
$ git config --global --list        
 
# Transforms the current directory into a Git repository; the command is same for creating repo from ..contd..
# scratch or convert an existing unversioned code base to a git repository           
$ git init
                                               
Command Summary - Accessing Git Help system
# general help
$ git help
# lists sub-commands
$ git help -a
# lists concept guides
$ git help -g
# read about a specific sub-command
$ git help
# read about a specific concept
$ git help

Copying a GitHub repository
$ cd
$ git clone https://github.com//
$ cd example_project
$ ls -al 



Adding your changes
# home directory
$ pwd                        
$ cd git-fast
$ ls
$ cd myRepoFromScratch
$ ls

# create a file and add some content
$ vi demoFile1                  
$ cat demoFile1
$ git status
$ git add demoFile1
$ git rm --cached demoFile1
$ git status


Committing changes

 # home directory
$ pwd                            
$ git status
$ git add demofile1
$ git status
$ git commit -m "our first commit in this course"
$ git status


Command Summary - add and commit

$ git add
$ git commit -m "message goes here"

How to check your repo status
# cd to /c/Users/HP-PC/git-fast/myRepoFromScratch
$ pwd
$ ls

# start with a clean working directory
$ git status                

# create file and add some contents such as "I want to shed 15 kg 5 weeks"      
$ vi weightLossChart    

# create file and add some contents such as "I want to add more green vegetables to my diet"  
$ vi dietChart                
$ git status           

 # same as "git status" since "long" option is the default one (compare output)  
$ git status --long      
$ git status -s                                 # status "??" for untracked file
$ git add weightLossChart
$ git status -s                                 # status "A"
$ git commit -m "1st commit for weightLossChart"
$ git status -s   
$ vi weightLossChart                 # make some changes to the file
$ git status -s                              # status "M"
$ git add weightLossChart
$ git status -s                                # status "M"
$ git commit -m "2nd commit for weightLossChart"
$ git status -s 
$ mv weightLossChart weightLossChart2
$ git status -s                             # status "D"


How to check commit history

# displays the entire commit history using the default formatting
$ git log                

# oneline condensed view of each commit history                    
$ git log --oneline

# Only display commits that include the specified file                           
$ git log           

# Show only commits that occur between and . Both arguments can be either a commit ID ...contd.
# a branch, name, HEAD, or any other kind of revision reference.                  
$ git log ..                     

# Limit the number of commits by . For example, git log -n 3 will display only 3 commits.
$ git log -n                           


Command Summary - status & log

# provides a status report of the repo
$ git status             

# displays the entire commit history using the default formatting                     
$ git log                

 # oneline condensed view of each commit history                    
$ git log --oneline           

# Only display commits that include the specified file               
$ git log      

# Show only commits that occur between and . Both arguments can be either a commit ID, a branch
# name, HEAD, or any other kind of revision reference.                      
$ git log ..                    

# Limit the number of commits by . For example, git log -n 3 will display only 3 commits.
$ git log -n                          

LECTURE - Checking out commits in a Git repository - Part 1

$ cd git-fast
# created a fresh git repository named "demo-checkout-commit" using initializr.zip
# Build up a commit history by modifying the file robots.txt, say 5 times and committing each time
# Let us assume we have one commit whose id/hash is 91770af
# the choice of commit id 91770af is arbitrary

# note where the HEAD is now (since HEAD will change later while doing a checkout)
$ git log --oneline

# clear the screen
# The command below will put you in a detached HEAD state.
# HEAD no longer points to a branch; it points directly to a commit.
$ git checkout 91770af



LECTURE - Checking out commits in a Git repository - Part 2

# you are in detached HEAD state and inside git repository (demo-checkout-commit)
# You can see only commits till commit-id 91770af
$ git log --oneline

# now edit and do a express commit for file robots.txt
# note down your new commit id/hash (Say ID1)
$ git log --oneline

$ git checkout master

# changes made in detached HEAD state is no more there
# the new commit ID1 is not visible
$ git log --oneline

# again you are in detached HEAD state
$ git checkout 91770af

# the new commit ID1 is not visible which means earlier changes...
# in detached HEAD state were not preserved
$ git log --oneline

# now we want to retain our commit i.e, preserve our changes
# make changes in the robots.txt and do an express commit

# create a branch named weird-experiment
$ git branch  weird-experiment

$ git checkout master
# the new commit id is not visible here
# you can check the file robots.txt using cat command also
$ git log --oneline

# new commit id is visible now
# you can examine the file robots.txt using cat command
$ git checkout weird-experiment



LECTURE - Checking out files

# cd to git repository (demo-checkout-commit) used in previous lecture
$ git log --online

# Let us assume we have the commit-id 91770af

# step-2: examine the current contents of the file
$ cat robots.txt

# now we will able to see the content of the file as at commit-id 91770af
$ git checkout 91770af robots.txt

# this will show the file has been added to staging area
$ git status

# step-5: examine the contents of the file (should be different from step-2)
$ cat robots.txt

# if we do not want to revert back the file robots.txt
$ git checkout HEAD robots.txt

# you will see a clean working directory
$ git status

# now we want to revert back to previous version of robots.txt as at commit-id 91770af
$ git checkout 91770af robots.txt
$ git commit -am "reverting back file state to commit 91770af"

# clean working directory
$ git status


# file is reverted and the contents are as seen in step-5
$ cat robots.txt  



LECTURE - Reverting changes

# cd into repository "undo-demo-git-repo"

# add the text say, "line 5"
$ vim checkoutfile.txt

# modified stage visible
$ git status

# commit the above change
$ git commit -am checkoutfile.txt "commit message..."

$ git log --oneline
$ cat checkoutfile.txt

# Now let's assume the earlier commit is a buggy one and so we will revert it
# revert command introduces a new commit in a safe manner (opens the default editor)
$ git revert HEAD

# check commit history - a new commit for revert
$ git log --oneline

# note the change made earlier has been reverted "line 5" is not visible
$ cat checkoutfile.txt



LECTURE - Resetting Git repository - Part1

# we are in repository git-reset-demo-1 with 2 files goldies-time-table and jimmys-time-table
# the repository has an existing commit history

# now edit file jimmys-time-table and add a line at the end
$ vim jimmys-time-table

# add the change to staging area
$ git add jimmys-time-table

# change in staging area is visible
$ git status

# undoes changes in staging area
$ git reset jimmys-time-table

# changes in staging area is removed; file in modified state
$ git status

# the changed in working directory is intact
$ cat jimmys-time-table



LECTURE - Resetting Git repository - Part2

# we are in repository git-reset-demo-2 (this repo is clone of git-reset-demo-1)

# edit file and add one line at the end
$ vim jimmys-time-table

# edit file and add one line at the end
$ vim goldies-time-table

# files are in modified state
$ git status

# add both files to staging area
$ git add .

# changes visible in staging area
$ git status

# "reset" command removes changes in staging area leaving the working directory intact
$ git reset

# both files in modified state
$ git status

#######################################
# git reset demo using the --hard option
# we are still in git-reset-demo-2 repository(this repo is clone of git-reset-demo-1)

# files are in modified state
$ git status

# add both files to staging area
$ git add .

# changes visible in staging area
$ git status

# --hard option removes all changes in working directory and staging area
$ git reset --hard

# the working directory is clean since all changes have been reset in working dir and staging
$ git status



LECTURE - Resetting Git repository - Part3

# we are inside git-reset-demo-4 repository (this repo is clone of git-reset-demo-1)

# Let's say, we have 5 commits in the commit history
# let' say, the 5th commit-id (HEAD) is 9166e4f and 4th commit-id is d21a539
$ git log --oneline

# let's reset the repository to 4th commit-id
$ git reset d21a539

# the 5th commit-id(9166e4f) has been removed from history and the HEAD is now at d21a539
$ git log --oneline

# the files are in modified state and changes in staging area has been removed
# the files are jimmys-time-table and goldies-time-table
$ git status

# now we will commit the above changes in working dir in 2 smaller chunks
$ git add jimmys-time-table
$ git commit -m "commit message....."

# now only goldies-time-table changes are visible in modified state
$ git status

$ git add goldies-time-table
$ git commit -m "commit message....."

# clean working directory
$ git status

$ git log --oneline



# we are in git-reset-demo-5 repository (this repo is clone of git-reset-demo-1)

# let's say there are 5 commits
$ git log --oneline

# now we will reset to the 3rd commit-id a53f51c (2 commits before HEAD) with the --hard option
# this command will remove 4th & 5th commit-ids as well removed all changes in working dir and staging area
$ git reset --hard a53f51c

# the 4th and 5th commit-ids has been removed from history
$ git log --oneline

# examine the file contents to confirm things
# the lines pertaining to 4th and 5th commit-ids has been removed
$ cat goldies-time-table
$ cat jimmys-time-table



LECTURE - Cleaning Git repository

$ cd git-fast
$ mkdir git-clean-demo
$ cd git-clean-demo

# create an empty repository
$ git init

# create few empty files
$ touch clean-demo-file
$ touch clean-demo-tracked-file

$ git add clean-demo-tracked-file
$ git commit -m "commit tracked file"

# shows clean-demo-file as an untracked file
$ git status

# -n option allows to make a dry run of "git clean" command
$ git clean -n

#################################################

# -f option (-f means force) removes untracked files from current directory
# so this will remove clean-demo-file
$ git clean -f

#################################################

$ mkdir clean-demo-dir
$ cd clean-demo-dir

# create an untracked file
$ touch clean-demofile-2

$ cd ..

# removes untracked file in path clean-demo-dir
$ git clean -f clean-demo-dir/

#confirm untracked file cleaning
$ cd clean-demo-dir

# "ls" produces no results meaning the untracked file was cleaned
$ ls

#################################################
$ cd ..
$ ls
$ touch clean-demo-file-2
$ ls

# -df option cleans both untracked files and directories
$ git clean -df
$ ls

#################################################
# create .gitignore file and add the file name "clean-demo-file-5"
$ vim .gitignore
$ git add .gitignore
$ git commit -m "committing .gitignore file"

$ touch clean-demo-file-4
$ touch clean-demo-file-5
$ ls -al

# -xf option cleans all untracked files including those mentioned in .gitignore file
$ git clean -xf

$ ls

Command Summary - pull and push
$ git pull

# cloning generally sets up both the names "origin and master" for you automatically
$ git push origin master 


Checking existing SSH Keys
$ ls -al ~/.ssh         # Lists the files in your .ssh directory, if they exist


Generate an SSH Key

# Generates public/private rsa key pair with default values - DON'T RUN THIS ONE
$ ssh-keygen           

 # 't' for type of key, 'b' for length of key, 'C' for comment for maintaining multiple keys                              
$ ssh-keygen -t rsa -b 2048 - C "home machine"

        

Enable SSH Agent & add the SSH Key to the agent

# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"        

# Add your SSH key to the ssh-agent  
$ ssh-add ~/.ssh/id_rsa.pub           


Testing SSH connection

# Verify SSH connection; here 'git" is the user name; note that you cannot use your github user name such as 'william'
$ ssh -T git@github.com                 

# another alternative way to verify if firewall issues are present
$ ssh -T -p 443 git@github.com          


Remote URL switching and SSH push

# List your existing remotes in order to get the name of the remote you want to change
$ git remote -v      

 # set remote URL
$ git git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git       

 # Verify new remote URL
$ git remote -v                                


Changing passphrase

# for changing password occasionally
$ ssh-keygen -p          

Installing and Configuring text editor (Sublime Text) for Git on Windows

# Specifying -w will cause the subl command to not exit until the file is closed
$ git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"

Installing and Configuring text editor (Sublime Text) for Git on Linux

# extract downloaded file - you can use "tar --help"...CONTD
# to see the meaning of the options "xvzf"
$ tar vxjf "sublime_text_3_build_3059_x32.tar.bz2"
 
# It is common to locate 3rd-party applications in..CONTD
# the /opt/ directory, so move the extracted files there
$ sudo mv sublime_text_3 /opt/
 
# make a Bash script which will allow us to execute..CONTD
# Sublime Text 3 with a simple command
$ cd /opt/sublime_text_3
 
# create file subl ; vim is improved vi
$ vim subl
 
# add these 2 code lines to file subl
# see below *** for command meaning
#!/bin/sh
exec /opt/sublime_text_3/sublime_text "$@"
 
# This allows anyone to read or execute the script, but only the owner can write to it.
$ sudo chmod 755 subl
 
# moving to /usr/bin
# This is the primary directory of executable commands on the system.
$ sudo mv subl /usr/bin/
 
# Specifying -w will cause the subl command to not exit until the file is closed
$ git config --global core.editor "subl -w"
 
# test to see whether sublime text is the default editor now
$ git config --global --edit



Installing and Configuring text editor (Sublime Text) for Git on Mac

# Create the symlink
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

# # test to see whether sublime text is the default editor now
$ git config --global core.editor "subl -n -w"

** CONTD : means "continued"

Installing and Configuring text editor (Sublime Text) for Git on Windows

# Specifying -w will cause the subl command to not exit until the file is closed
$ git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"

Installing and Configuring text editor (Sublime Text) for Git on Linux

# extract downloaded file - you can use "tar --help"...CONTD
# to see the meaning of the options "xvzf"
$ tar vxjf "sublime_text_3_build_3059_x32.tar.bz2"
 
# It is common to locate 3rd-party applications in..CONTD
# the /opt/ directory, so move the extracted files there
$ sudo mv sublime_text_3 /opt/
 
# make a Bash script which will allow us to execute..CONTD
# Sublime Text 3 with a simple command
$ cd /opt/sublime_text_3
 
# create file subl ; vim is improved vi
$ vim subl
 
# add these 2 code lines to file subl
# see below *** for command meaning
#!/bin/sh
exec /opt/sublime_text_3/sublime_text "$@"
 
# This allows anyone to read or execute the script, but only the owner can write to it.
$ sudo chmod 755 subl
 
# moving to /usr/bin
# This is the primary directory of executable commands on the system.
$ sudo mv subl /usr/bin/
 
# Specifying -w will cause the subl command to not exit until the file is closed
$ git config --global core.editor "subl -w"
 
# test to see whether sublime text is the default editor now
$ git config --global --edit

Installing and Configuring text editor (Sublime Text) for Git on Mac
# Create the symlink
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

# # test to see whether sublime text is the default editor now
$ git config --global core.editor "subl -n -w"

** CONTD : means "continued"

Git diff command:
1. Difference b/w working directory and staging area:
git diff
git difftool
git diff --staged
git diff --cached
2. Difference b/w working directory and commit area
git diff HEAD
git difftool HEAD
3.Difference b/w staging area and commit area
git diff --staged HEAD
git diff --cached HEAD
4. Difference b/w orbitraory commit
git diff dsf3434  sdfds345
5. git diff master origin/master
git log command:
1.git log --oneline --decorate  --graph --all
2.git log --oneline --decorate  --graph
3. git log --stat
4. git log --oneline -n 2
5. git log -p
6. git log -p --oneline -1
7. git log --oneline grep="quick-feature"

git branch -a  a means all local and remote branch
git branch small-feature
git branch -m small-feature quick-feature
git branch
git branch -d quick-feature
git checkout small-feature
git branch -D small-feature  -->it is forcefully deleted


git merge demorbracnh
git merge demobranch --no-ff

git mergetool
git commit --amend --no-edit

git reflog
git show HEAD@{52}
.git/logs
git log -g master


git stash
git stash list
git stash save "modified line dimension-404.html"
git stash show stash@{2}
git stash -u
git stash apply stash@{2}
git stash drop stash@{4}
git stash pop stash@{1}
git stash clear
git stash branch demobranch
git branch -D brnachname
git stash apply --index
git stash --keep-index


git tag v-1.8-rc1
git tag
git tag --list
git show v-1.8-rc1
git tag -a v-1.9-rc2 -m "release version 1.9"
git tag -annaoted v-1.9-rc2 -m "release version 1.9"
git cat-file -t v-1.9-rc2
git tag -l "v-2.1,5*"
git tag --list "v-2.1,5*"
git tag
git tag -a v-3.1.0 -m  "Release 3.1"
git diff v1  v2
git tag -a v2  f--force 198a296
git tag v2 --delete
git push origin --tags

Monday, July 22, 2019

Gitub Practice

GITUB:
We can manage our version.
pwd
ls
cd Documents
ls
cd Gitdemo
ls
git init ->Initialized empty Git repository
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (awgfile)
$ git init
Initialized empty Git repository in C:/Users/Nethra/Documents/GitHub/.git/
$ git --version
git version 2.22.0.windows.1

Dont touch GIT files:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ ls -al
total 47136
drwxr-xr-x 1 Nethra 197121        0 Jul 23 03:29 ./
drwxr-xr-x 1 Nethra 197121        0 Apr 30 02:21 ../
drwxr-xr-x 1 Nethra 197121        0 Jul 23 03:29 .git/
Git add
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
No commits yet
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter1.txt
        letter2.txt
nothing added to commit but untracked files present (use "git add" to track)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git add letter1.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
No commits yet

Changes to be committed:
  (use "git rm --cached ..." to unstage)
        new file:   letter1.txt   --->staged, need to commit
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt   ->Working copy

Git configuration Settings:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git config --global user.name "rameshexpvodat"
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ 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.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
credential.helper=manager
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
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
user.name=rameshexpvodat
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git config --global user.email "rameshexpvodat@gmail.com"

Git commit
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
git status
On branch master
No commits yet
Changes to be committed:
  (use "git rm --cached ..." to unstage)
        new file:   letter1.txt
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git commit -m "commiting on the first file"
[master (root-commit) e6d8f60] commiting on the first file
 1 file changed, 1 insertion(+)
 create mode 100644 letter1.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt
nothing added to commit but untracked files present (use "git add" to track)

Adding all files in one go:

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt
        letter3.txt
nothing added to commit but untracked files present (use "git add" to track)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git add .
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
        new file:   letter2.txt
        new file:   letter3.txt

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ clear

Git Unstage:
From the staging areas to working copies
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
        new file:   letter2.txt
        new file:   letter3.txt

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git reset head
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt
        letter3.txt
nothing added to commit but untracked files present (use "git add" to track)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git add .
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
        new file:   letter2.txt
        new file:   letter3.txt

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git reset HEAD letter2.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD ..." to unstage)
        new file:   letter3.txt
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter2.txt

Checking the Git differences:
compare Git local and staging area
compare Git local and working copies
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git diff
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git diff letter2.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git diff --staged
diff --git a/letter3.txt b/letter3.txt
new file mode 100644
index 0000000..b14c750
--- /dev/null
+++ b/letter3.txt
@@ -0,0 +1 @@
+this is my third file
\ No newline at end of file
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git add .
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git reset HEAD
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git add .
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git reset HEAD letter3.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master

Changes to be committed:
  (use "git reset HEAD ..." to unstage)
        new file:   letter2.txt
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter3.txt

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git commit -m "commiting letter2.txt"
[master ce57d3d] commiting letter2.txt
 1 file changed, 1 insertion(+)
 create mode 100644 letter2.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified:   letter2.txt
Untracked files:
  (use "git add ..." to include in what will be committed)
        letter3.txt
no changes added to commit (use "git add" and/or "git commit -a")
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git diff
diff --git a/letter2.txt b/letter2.txt
index 3d37eb2..b73eda8 100644
--- a/letter2.txt
+++ b/letter2.txt
@@ -1 +1 @@
-my second file
\ No newline at end of file
+my tenth file
\ No newline at end of file

Git remote:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git remote add firstremote "https://github.com/rameshgit12/gitDemo.git"
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git remote
firstremote

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git remote add second "git@github.com:rameshgit12/gitDemo.git"
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git remote
firstremote
second
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git remote -v
firstremote     https://github.com/rameshgit12/gitDemo.git (fetch)
firstremote     https://github.com/rameshgit12/gitDemo.git (push)
second  git@github.com:rameshgit12/gitDemo.git (fetch)
second  git@github.com:rameshgit12/gitDemo.git (push)
pushing changes to gitub:
$ git remote -v
firstremote     https://github.com/rameshgit12/gitDemo.git (fetch)
firstremote     https://github.com/rameshgit12/gitDemo.git (push)
second  git@github.com:rameshgit12/gitDemo.git (fetch)
second  git@github.com:rameshgit12/gitDemo.git (push)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git push -u firstremote master
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (10/10), 790 bytes | 197.00 KiB/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To https://github.com/rameshgit12/gitDemo.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'firstremote'.

what is and how to create branch:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git branch
* master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git branch gitdemo1
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git branch
  gitdemo1
* master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git status
On branch gitdemo1
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified:   letter2.txt
no changes added to commit (use "git add" and/or "git commit -a")
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git add letter2.txt
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git commit -m "commiting changes to letter2.txt"
[gitdemo1 3bce886] commiting changes to letter2.txt
 1 file changed, 1 insertion(+), 1 deletion(-)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git push -u firstremote gitdemo1
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 bytes | 164.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'gitdemo1' on GitHub by visiting:
remote:      https://github.com/rameshgit12/gitDemo/pull/new/gitdemo1
remote:
To https://github.com/rameshgit12/gitDemo.git
 * [new branch]      gitdemo1 -> gitdemo1
Branch 'gitdemo1' set up to track remote branch 'gitdemo1' from 'firstremote'.
Merge the branches:
git checkout master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'firstremote/master'.
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git branch
  gitdemo1
* master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git merge gitdemo1
Updating 771b459..3bce886
Fast-forward
 letter2.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git status
On branch master
Your branch is ahead of 'firstremote/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git push -u firstremote master
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/rameshgit12/gitDemo.git
   771b459..3bce886  master -> master
Branch 'master' set up to track remote branch 'master' from 'firstremote'.
Deleting and Renaming the branches:
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git branch gitdemo2
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (master)
$ git checkout gitdemo2
Switched to branch 'gitdemo2'
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo2)
$ git checkout -b gitdemo3
Switched to a new branch 'gitdemo3'
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo3)
$ git branch -d gitdemo2
Deleted branch gitdemo2 (was 3bce886).
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo3)
$ git branch
  gitdemo1
* gitdemo3
  master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo3)
$ git branch -d gitdemo3
error: Cannot delete branch 'gitdemo3' checked out at 'C:/Users/Nethra/Documents/GitHub'
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo3)
$ git checkout gitdemo1
Switched to branch 'gitdemo1'
Your branch is up to date with 'firstremote/gitdemo1'.

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git branch -d gitdemo3
Deleted branch gitdemo3 (was 3bce886).
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git branch -m
fatal: branch name required
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (gitdemo1)
$ git branch -m gitdemo1 git123
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git branch
* git123
  master
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git remote -v
firstremote     https://github.com/rameshgit12/gitDemo.git (fetch)
firstremote     https://github.com/rameshgit12/gitDemo.git (push)
second  git@github.com:rameshgit12/gitDemo.git (fetch)
second  git@github.com:rameshgit12/gitDemo.git (push)
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git remote rm second
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git remote -v
firstremote     https://github.com/rameshgit12/gitDemo.git (fetch)
firstremote     https://github.com/rameshgit12/gitDemo.git (push)
Deleting and Changing URLs for remotes:

Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git remote set-url firstremote https://github.com/rameshgit12/test.git
Nethra@LAPTOP-JR9FSSG9 MINGW64 ~/Documents/GitHub (git123)
$ git remote -v
firstremote     https://github.com/rameshgit12/test.git (fetch)
firstremote     https://github.com/rameshgit12/test.git (push)

















Python Challenges Program

Challenges program: program 1: #Input :ABAABBCA #Output: A4B3C1 str1="ABAABBCA" str2="" d={} for x in str1: d[x]=d...