Day 8 Task: Basic Git & GitHub for DevOps Engineers.
Sayali Shewale
DevOps Engineer | AWS cloud Engineer | AWS DevOps | Linux | Docker | Jenkins | Terraform | Kubernetes | Ansible | Grafana
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 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 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:
sudo apt-get update
sudo apt-get install git
Create a new repository on GitHub and clone it to your local machine
To create a new repository on GitHub:
1. Go to github.com and log in to your account.
To clone the repository to your local machine, follow these steps:
2. Above the list of files, click??Code.
领英推荐
3. Copy the URL for the repository.
4. Open?terminal and Change the current working directory to the location where you want the cloned directory.
5. Type?git clone, and then paste the URL you copied earlier.
git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
Make some changes to a file in the repository and commit them to the repository using Git.
1 . Create a file using vi editor.
2. git status - show the status of your git repository
3. git add - Moves changes from the working directory to the staging area.
Add files to git - git add <file_name>
Add all the current directory files to git - git add .
4. git commit - commit all the staged files to git.
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
git push - The?git push?command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo.
Syntax : git?push?<remote>?<branch>
Thank you for taking time to read this article!
Helping Students and Professionals build their Careers | Experience in DevOps | Python | AWS | PySpark | SQL | NoSQL | 1000+ Learners placed
1 年keep learning, keep growing Sayali Shewale