Day 8 Task: Basic Git & GitHub for DevOps Engineers.
Task:
- Install Git on your computer (if it is not already installed). You can download it from the official website at https://git-scm.com/downloads
- Create a free account on GitHub (if you don't already have one). You can sign up at https://github.com/
- Learn the basics of Git by reading through the video This will give you an understanding of what Git is, how it works, and how to use it to track changes to files.
Git is a VCS tool- that provides file tracking regarding when and who created, modified, and deleted the file. Also you can revert the modification done to it.
Following are the basic git commands:
$ git init
--------------->To initialize the current directory as a git repo.
$ git status
------------>Check git repo and Local FS are in the same state or not.
$ git add
---------------->Add file to the staging area
$ git commit -m
----------> Add file to git repo to start tracking it
$ git log
------------------>check git operations history
$ git restore
------------>to get the last committed state of a particular file
$ git config --global
user.name
"username"
--------->Add user details because git keeps track of committers' activity
$ git config --global
user.email
"user_email_add"
---->Add user details because git keeps track of committers' activity
$ git rm --cached
------> to remove the file from the staging area before committing it
$ git rm --cached -f
------------------------> to removed from staging area
$ git remote -v
-----------------> Check remote access available to your local repo
$ git remote add origin
----------> add remote access to server repo
$ git push origin master
----------->push commit from local master branch to remote
$ git push origin main
--------->push commit from the local main branch to the remote
$ git checkout -b dev
--> Create a new branch-dev from the parent and switch to it
$ git diff master
-----------> Check the diff between the current and master branch
$ git branch
------------------------>check branches available
$ git switch
------->switch to a different branch
$ git branch -d
-------->delete particular branch
$ git clone </repos/URL/>
------------->clone the remote repo to local machine
Exercises:
- Create a new repository on GitHub and clone it to your local machine
- Make some changes to a file in the repository and commit them to the repository using Git
- Push the changes back to the repository on GitHub
Day08 task is completed!
90DaysOfDevOps Tasks👇