👋Hi Everyone,
Welcome to Day 08 (Part-2) of the #90DaysofDevops learning journey. In this article, we will cover about GithHub and its importance, how to create a repository, and clone a repository.
🔶 What is Github?
GitHub is a Git repository hosting service.
The version control system Git is hosted on the internet via GitHub. Developers, DevOps teams, and businesses of all sizes use it extensively to manage their source code repositories, collaborate on code with others, and create software applications.
Here are a few reasons why GitHub is a popular choice for version control:
🔸 Collaboration:
GitHub makes it simple to work on code with others, no matter where they are in the world. It offers tools like pull requests, code reviews, and problem tracking that make team collaboration easier and more productive.
🔸 Community:
GitHub has a large and active community of developers, who share code, contribute to open-source projects, and offer support and guidance to others.
🔸 Integration:
GitHub integrates with many other programs and services, including Jenkins, Travis CI, Docker, and Amazon. As a result, adding GitHub to your current DevOps operations is simple.
🔸 Accessibility:
Because GitHub is accessible from anywhere with an internet connection, it is simple to manage and collaborate on code from anywhere in the world.
🔸Security:
GitHub offers a variety of security features, such as two-factor authentication, encrypted connections, and granular access controls. This helps to ensure that your code and data are secure and protected.
🔸Open source:
GitHub is an open-source platform, which means that its code is freely available for others to use and contribute to. This has contributed to the popularity of GitHub among open-source developers and communities.
🔶 Create a new repository on GitHub and clone it to your local machine
To create a new repository in GitHub, follow these steps:
Log in to your GitHub account and click the "+" sign in the upper right-hand corner of the dashboard.
Select "New repository" from the dropdown menu.
Choose a name for your repository.
For example, now we will create a repository name "Python_Notes"
Optionally, add a description for your repository.
In the description box "Python study material for beginners"
Choose whether you want your repository to be public or private. Public repositories are visible to everyone, while private repositories require authentication to access.
Select whether you want to initialize your repository with a README file, which is a good practice to give an overview of your project.
Choose a license for your repository if you wish to make it available for reuse by others.
Click the "Create repository" button.
Once you have created your repository, you can start adding files, making commits, and pushing changes to the repository. You can also invite collaborators to work on the repository with you, manage access permissions, and track issues and pull requests.
So, successfully created the "Python_Notes" repository.
select Create a New file.
So, we will create the first Python Program file i.e. "welcome.py"
click on "Commit new file" with a commit message "first commit in the welcome file"
check the file "welcome.py" created in the "Python_Notes" repository.
🔶 Clone a GitHub Repository
Cloning a remote in Git creates a local version of that repository on your machine, allowing you to explore in a safe space without impacting the source code.
Cloning also establishes a connection between the local repository on your machine and the remote repository, allowing push and pull actions with the remote project.
Go to your repository on GitHub. In the top right above the list of files, open the Clone or Download drop-down menu. Copy the URL for cloning over HTTPS.
next step Check if the repository has been created and copy the GitHub repository(HTTPS) URL
https://github.com/CloudDevopsJourney/Python_Notes.git
Open GitBash Terminal Cloning an Existing Repository from GitHub to your local Machine.
If you want to get a copy of an existing Git repository — for example, a project you’d like to contribute to — the command you need is git clone
.
git clone https://github.com/CloudDevopsJourney/Python_Notes.git
Now you can see on your local machine cloned repository.
Open the GitBash terminal, and run the command py welcome.py
file.
🔶 Push the changes back to the repository on GitHub
Now edit py welcome.py
file and add a new line in the file. with the help of the vi editor.
vi editor will open and press the Esc
button -->press i
for insert Mode--> modify file --> press Esc
then:wq!
and press Enter
After modifying the file content once again run the command py welcome.py
🔶 Push the changes back to the repository on GitHub
A remote repository (often called a remote), is a Git repository hosted on the Internet or some other network.
First, execute the git remote –v
command to check available remote URL
git remote -v
Type
git push
to push the changes to the remote repository on GitHub.You can use
git push origin
orgit push origin main
(Note: here
main
is the branch name)git push origin
Enter your GitHub username and password if prompted.
Verify that the changes are pushed to the remote repository by visiting your repository's page on GitHub.
It's important to note that if there are conflicts between your local repository and the remote repository on GitHub, you may need to resolve those conflicts before pushing your changes. Also, make sure that you have the necessary permissions to push changes to the repository.
🎉 Task Done👍 Day 08 of #90daysofdevops 💯
In this article, we have covered the Day 08 (Part-2) task and learned about GitHub and its importance.
You can store a variety of projects in GitHub repositories, including open source projects, you can share code to make better, more reliable software.
Overall, GitHub is a powerful and flexible platform that provides a range of features and benefits for version control and collaboration. Its popularity and community make it an attractive choice for developers and organizations of all sizes.
If you enjoyed this article please like it and share it with your friends and colleagues!
Thank you for reading🤓