Git tutorials

Day -15

GitHub is a developer platform that allows developers to create, store, manage and share their code.

Launch ec2 instance aws linux

install git

verify git installed or not

verify git version

git global configuration

create one more instance

install git

Check git installed or not

git global configuration

login github.com

create repository

DAY - 16

login first ec2 instance; then create one directory called mumbaigit then see the content

login a directory

git init

create one file

edit content

git status

now file send to work directory to staging area

now check status

now file moved from staging area to local repo

now check status

list out commits

see the data in commit id

list

push an existing repository from the command line

see the branch

rename branch

now push

commit has been done

see the content

see the content

Now login another machine

mkdir londongit

initialize git

from local repository to central repository

now pull

see the branch name

Rename

now see the git branch

list

see the content

now see the git log

show the content

Add a content for myfile from london ec2

now see git status

git add

now see the status

commit

see the git status

how many commits are there

see the data with commit

now see the file one line found (commit from mumbaiec2)

now push

refresh page; now see the file (commit from londonec2)

login mumbai ec2; view the file

view git log

pull

now view file

how many commits are there

see the data of the commits

add line from mumbaiec2

git status

git add

git commit

git log

git show

now see last update from london commit

now see 2 lines

push

now see the three lines found

see different commits

Day -17 git ignore

A .gitignore file is a text file that tells Git which files and folders to ignore. It is placed in the root directory of your repository and is used to exclude files that you don't want to be tracked by Git. This can be useful for a variety of reasons, such as excluding sensitive files, build artifacts, or temporary files.

login mumbai ec2

inside mumbaigit

create one file .gitignore

add this content for ignore class file

git status

add file

git commit

git status

create files

git status now see complete ignore class files; only consider txt,java files but ignore class file

create one class file then saw git status

now see complete class file

git add

see git status; see commit only java,txt file but ignore class file

git commit

now ignore *.demo files

see the git status

git add

git commit

create demo file

git status

git log; here see all the commits

i want see latest commit

see only two commits

summarize all commits

using grep

git show

create branch

now see two branches

switched to a branch

git branch

ls

git log

git branch

ls

checkout

ls

git branch

now checkout;

ls

git log

create one file

see the content of file

git status

git add

git commit

ls rajfile found; the same file not found in this branch sundarbio.github.io

now switch to sundarbio branch

now see total six commits

ls (you dont see the rajfile)

now switch to newbranch

create a harifile

inside content

now switch sundarbio branch

now harifile not happen add,commit in newbranch so we see this file both branch

now switch to newbranch now see harifile see here also

git add,commit; now harifile belongs to newbranch; we do not see sundar branch

now switch sundar branch; now do ls harifile not found because this file belongs to newbranch

Git Merge

Git merge is a command that is used to combine changes from two or more branches into a single branch. When you merge two branches, Git will create a new commit that includes the changes from both branches.

now sundar branch

ls here rajfile harifile not found ; git log

git merge

ls; now see harifile,rajfile found

git log

git push

now see all the files pushed centralrepo

Day -18

Git conflict

A Git conflict occurs when Git is unable to automatically merge changes from two branches. This can happen when two people have made changes to the same file in different branches, or when a file has been deleted in one branch but modified in another.

git branch

create a testfile

inside content

git add

git commit

branch checkout

git branch

create testfile

inside content

git add

git commit

switch a sundar branch

git merge; error occurred

Edit testfile

now see the data

now i am going to modify like below

git add

git commit

git branch

git log

git show

view testfile

git push

see the file

Git stash

Git stash is a command that allows you to save your uncommitted changes and revert your working directory to a clean state. This can be useful if you need to switch branches or work on a different task, but you don't want to lose your current changes.

git branch

create a file

git add; git commit

edit demofile

git stash

now demofile empty

stash list

edit demofile

inside content

git status

git stash

open demofile

git status

git stash list

git stash apply

open demofile

edit demofile

add this content

git add ;git commit

git status

open demofile

git stash list

merge conflict

see the demofile

then edit; save this file

git add; git commit

git log

git stash list; git stash clear; clear the stash list no list found after

Git reset

The git reset command is used to undo the changes in your working directory and get back to a specific commit while discarding all the commits made after that one.

ls

create one file

inside content

git status

git add; git status

see file spelling mistake; so now we go to before commit state; so run the git reset

git reset(it works an before commit)

now see untracked samplefile

ls

git status

git add

git status

snapshot deleted and respective file also deleted

now see sample file deleted

Git revert

Git revert is a command that is used to undo the changes that were made in a previous commit. It does this by creating a new commit that reverses the changes of the previous commit. This is useful when you want to undo a commit that you have already pushed to a remote repository.

create samplefile

inside content

git add

git commit

git log

git show

ls

open file; there is mistake sample file but here sampe file

git log

git revert 08c690a

before this file like this

after edit

result

ls

git status

git log

Day 19

ls

git push

see github

ls

Create devopsfile

inside

git add; git commit

git push

now see the file in github

now edit the content

git add

git commit

git push

see the content

if you want older data; click commits

you can see two file

open devopsfile see the old data

see the latest commits

ls; remove devopsfile

git status

git add

git status; see snapshot deleted

git commit

git log

git show

now see the devopsfile in github

ls we cannot see devopsfile

git push

now see devopsfile deleted

if you want old data click commit; opendevopsfile modified

now see the old data

now we manage multiple person edit same file

Create a file

git status; now see all untracked files

remove untracked files

ls now not saw file1 to file5

git log

assgin tag for hari tag id 38a2339

now see hari tag id got a tag

now use tag

list out tags

now delete hari tag

now see hari tag not found

now see no tag found