Saturday, April 26, 2025

Git Basic Commands

Git

Class 13th Git  Apr 26th Git (Global Information Tracker )

SDL (Software Development lifecycle)

1.Analysis  (Product Owner, Project Manager, Business Analyst, CTO (Chief technology officer)

2.Design(System Architect, System engineer)

3.Development (Front end dev, Backend dev, Devops)

4.Testing (QA, Tester, Devops)

5.Deployment (Admin, Devops)

6.Maintenance(Users,Testers,Support Managers )

These all project work end of the day it will store in the one repository maintained 

Above SDLC confirmation divided the scrums ,scrum master split the task into sprints 

All the source code maintained in central repository store ,that is version control tool, tracking the changes and rollback change feature it i will give you Git 

What is The version Control System ? & types

  • A version control system(VCS) is a tool that helps Softwate developers manage changes to source code over time
  • It keeps track of every modification to the code in a special kind of database.
  • Easy rollback compare to the earlier versions.

VCS Ensure that Developers can :
Collaborate without overwriting each other's work
Revert changes when errors occur.
Compare versions to see what change and why
Branch and merge to work on different feature independently

Type of Version control system
1. Local version control system (LVCS) :Single use not able to share
2. Centralized version control system (CVCS): Remark Always in internet always be available.
3. Distributed Version control system (DVCS) :99% using this System ,always internet not required

Popular Version control system:
Git (Global Information tracker, Git Hub, Gitlab,AWS CI/CD setup ,Bit bucket)

What is Git ?

  • In simple words,it is a distributed version control system(VCS).
  • High performance, Completed trackable and open-source tool
  • It can integrate with different other services like Jenkins,K8s,AWS CI/CD Setup,etc.
  • Github, and GitLab were developed on top of Git 

Different ways to use Git 
  • Command line interface(CLI)
  • GUI
  • Editors like visual Studio,visual Studio code,Eclipse etc.
Download Git 
https://git-scm.com/downloads/win
Git bash it will give you linux cmd line editor
Git has own database maintained backup
Commands
Git init (Initialize ,it means git will track the files by git ) 
 .git  (it hidden file once you go to project enter above command git will ready to track file from project)
Git add . (add all changed file to you repository local)
Git commit (this command will commit your changes to local repository)
Git Push (this command will push your change local to central git repository, you tell which origin you need move the file master or branch)
Git Stages :
Git has three main stages in its workflow.
1.Working directory (Untracked/Modified) Local
2.Staging area (index)    Local  Git add. 
3.Repository(committed)  Local Git commit 

Practice :
Step1:
Create one Project CCIT2025 public click create repository 

Step2:Clone the Project your local using using ssh key or http 
Step3:Prior to clone or commit the change to repository required to set global identity 

git config --global "vakati.subbu@gmail.com"
git config --global   "vakati.subbu"


Git Clone 
$ git config --global "vakati.subbu@gmail.com"
$ git config --global   "vakati.subbu"
vakati.subbu@gmail.com

$ git clone git@github.com:Vakatisubbu/CCIT2025.git
Cloning into 'CCIT2025'...
warning: You appear to have cloned an empty repository.

Git add 
Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos (master)
$ cd CCIT2025

Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git add .

Git Status 
Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git status
On branch main

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   Evenodd.java

Git Commit 
$ git commit -m "evenodd"
[main (root-commit) 476f36c] evenodd
 1 file changed, 21 insertions(+)
 create mode 100644 Evenodd.java
Git Push 
$ git push origin
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 608 bytes | 202.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:Vakatisubbu/CCIT2025.git
 * [new branch]      main -> main
Step4:


Step5: Evenodd.jave file just removed some space see below git status showing modified 
$ git status
$ git status
On branch main
Your branch is up to date with 'origin/main'.
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:   Evenodd.java
no changes added to commit (use "git add" and/or "git commit -a")
Step6: it will add all changed file to local repistory
git add .

On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   Evenodd.java
Step7:one more time commit 
 $ git commit -m "second commit"
[main d9ef6c9] second commit
 1 file changed, 1 insertion(+), 2 deletions(-)
Step8: it will give you all commits log history
$ git log --oneline
d9ef6c9 (HEAD -> main) second commit
476f36c (origin/main) evenodd
Step9: I have moved one more file Number.java moved local repository secondfile
Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Number.java
nothing added to commit but untracked files present (use "git add" to track)
Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git add .
Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   Number.java

Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)
$ git commit -m "secondfile"
[main 5ddcc74] secondfile
 1 file changed, 11 insertions(+)
 create mode 100644 Number.java

$ git log --oneline
5ddcc74 (HEAD -> main) secondfile
d9ef6c9 second commit
476f36c (origin/main) evenodd
Step10: now i am removed file from local repostory 
$ git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    Evenodd.java
no changes added to commit (use "git add" and/or "git commit -a")
Step11: Git restore using below command ,it restore form git hub repository 
$ git restore .

$ git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

git grants token using we can able to push the change to other repository 

Administrator@DESKTOP-AV2PARO MINGW64 /c/git_repos/CCIT2025 (main)

$ git push origin

Enumerating objects: 8, done.

Counting objects: 100% (8/8), done.

Delta compression using up to 4 threads

Compressing objects: 100% (5/5), done.

Writing objects: 100% (6/6), 765 bytes | 382.00 KiB/s, done.

Total 6 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)

remote: Resolving deltas: 100% (1/1), completed with 1 local object.

To github.com:Vakatisubbu/CCIT2025.git

   476f36c..5ddcc74  main -> main




No comments:

Post a Comment