WEEK4: BASIC GIT & GITHUB
#90DaysofDevops challenge
Q- What is Git?
Git is a distributed version control system that tracks changes in any set of computer files, usually used for coordinating work among programmers collaboratively developing source code during software development.
Q- What is Github?
GitHub is a code hosting platform for collaboration and version control.
GitHub lets you (and others) work together on projects.
Alternatives are GitLab, BitBucket, Launchpad etc
Repository
>> A repository is a place where you have all the codes or kind of folder on a server.
>> Changes are personal to a particular repository
Q- What is Version Control?
Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.
CVCS → Centralized Version Control System
DVCS → Distributed Version Control System
- Centralized Version Control System
>> It is not locally available, meaning we’ve always needed to be connected to a network to perform any action
>> Since everything is centralized, if the central server gets failed, you will lose the entire data
2. Distributed Version Control System
In DVCS, every contributor has a local copy or clone of the main repository which contains all the files and metadata of the main repository.
Q- Why do we need Source Code Management as a DevOps Engineer?
To use the CICD pipeline in DevOps, you must know the recent project updates. Because DevOps Monitors the most recent code and creates definitions that execute a variety of tasks to user needs.
GIT Three-Stage Architecture
Commit
>> When you store changes in a repository. you will get a commit-id
>> It is 40 Alpha-Numeric Characters.
Untracked >> Staged >> Tracked
Basics Git Commands
>> Set Global UserName and Email for Git(Locally)
Get Ashish Kumar’s stories in your inbox
Join Medium for free to get updates from this writer.
→ git config — global user.name “<your username>”
→ git config — global user.email “<your email>”
>> Get Global userName and Email for Git
→ git config — get user.name
→ git config — get user.email
- git init (Initialize an empty Git Repository)
- git clone <repository_url> (Clone an existing Git Repository)
- git add <file_name> (Add file/stage to git)
- git add . (Add all current directory files to git)
- git commit -m “<your_commit_message>” (Commit all staged files to git)
- Restore the file from being modified to tracked
→ git restore <file_name> (In case you deleted that file by mistake)
→ git restore — staged <file_name> (To unstage file)
→ git rm — cached <file_name> (To unstage file)
7. git status (Show the status of your git repository)
8. git branch (Show the branches of your git repository)
9. git checkout -b <branch_name> (Checkout to a new branch)
10. git checkout <branch_name> (Checkout to an existing branch)
or, git switch <branch_name>
11. git checkout -d <branch_name> (Remove a branch from git)
12. git remote -v (Show remote origin URL)
13. git remote add origin <your_remote_git_url> (Add remote origin URL)
14. git remote remove origin (Remove remote origin URL)
15. git revert <commit_hash_id> (Revert deleted files)
16. git push origin <branch_name> (Push your local changes to remote branch)
17. git pull origin <branch_name> (Pull your remote changes to the local branch)
18. git log (Check your git commits and logs)
>> git log — oneline (Show all commits in one line)
Thanks for reading my blog!!!!!!!
Please reach out in case you have any queries & questions related to this……..
Linkedin: https://www.linkedin.com/in/ashish-kumar-hit/
Email: ashishkr3246@gmail.com
Ashish Kumar










