Day 8 Task: Basic Git & GitHub for DevOps Engineers: Part-1
Deepak Patil
DevOps engineer with 3+yrs DevOps/ DevSecOps/ Cloud Experience in AWS?? | DevOps ?? Technologies ?????? Linux ??? | Git ?? | Terraform?? | Docker ?? | Kubernetes | EKS | HELM | ? | Jenkins ???.
What is Git?
Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.
With Git, you can keep a record of who made changes to what part of a file, and you can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.
What is GitHub?
GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.
What is Version Control? How many types of version controls do we have?
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.
There are two main types of version control systems: centralized version control systems and distributed version control systems.
Why do we use distributed version control over centralized version control?
Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.
Task:
Install Git on your computer:
(if it is not already installed). You can download it from the official website at download git and follow the steps
Here we will install git in Ubuntu (Linux os)
Create a new repository on GitHub and clone it to your local machine:
To create a new repository on GitHub:
To clone the repository to your local machine, and follow these steps:
5. Now go to the terminal and create the directory to clone the repository and go inside that newly created dir
6. Now clone the GitHub repository into your local machine(newly created directory)
领英推荐
To clone the GitHub repo use the below clone command
git clone https://github.com/YOUR-URL/YOUR-REPOSITORY
Which we have earlier copied use that URL
7. Now you can see your GitHub repository is successfully cloned in your local directory
Make some changes to a file in the repository and commit them to the repository using Git.
git status - Shows the current status of your git repository
3. Now we have to move the changes from the working area to the staging area using the below command
git add <file-name> or git add . (. add all the updated changes )
-?Moves changes from the working directory to the staging area.
4. Now we have to commit the changes(staged) file to git using the below command
git commit -m "your_commit_message"
Push the changes back to the repository on GitHub
You can request a list of all remote repositories that are currently connected to your local repository:
Syntax:? git remote -v
5. Now we have to push/upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo using the below command
git?push?<remote>?<branch>
6. It will ask you to enter GitHub username and then enter your username and password (git-hub token) to verify the identity
8. And now finally we can see the changes reflected in the Git-Hub repository also with the latest commits
Thank you for reading the article
Happy Learning!