Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers.
What is Git and why is it important?
Git stands for ' Global Information Tracker' its centralized version control systems. Git can be installed on your remote server and local server, we can maintain our central repository on remote server while others team members or developers can access remote server(remote repository) and maintain their version of software, code changes , track the versions of software and commit changes into remote server (remote repository).
What is difference Between Main Branch and Master Branch??
Historically, “master” was the default branch name used in Git repositories for many years. It originated from the original version control system called BitKeeper.
The “master” branch typically represents the main development branch, where the latest changes and features are integrated before being released or merged into other branches.
In response to the concerns raised about the term “master”, many Git hosting platforms and communities have moved towards adopting more inclusive naming conventions.
“main” is a commonly used alternative to “master” as the default branch name. It aims to promote diversity and inclusion within the software development community.
The “main” branch serves the same purpose as the “master” branch, representing the primary branch for development, integration, and the latest changes.
Can you explain the difference between Git and GitHub?
What is difference between local & remote repository? How to connect local to remote?
Remote repository is our centralize repository where we will maintain all the code of our application , can keep track on code, changes and commits. Remote repository could be on internet or offline server. Remote repository shared among all the team members where they can access it and maintain the version of code and changes with commits.
Local repository is available with individual user where individual user can clone the code or repository from remote repository and work on and after completing day to day task push it to the remote repository.
Creation of Remote repository
On Github or you can choose any platform your choice, create a new repository.
Copy the repository URL.
Initialize Local Repository:
Navigate to your local project directory using the command line.
Run the following commands to initialize a Git repository and make an initial commit:
git init git add . git commit -m "Initial commit"
Add Remote Repository URL:
Run the following command, replacing
<remote-url>with the URL you copied earlier:
git remote add origin <remote-url>
Push Local Repository to Remote:
Push your local repository to the remote repository
git push -u origin master
Set your user name and email address, which will be associated with your commits.
Create a repository named with "Devops" on GitHub.
Connect your local repository to the repository on GitHub.
git init # Initialize git repository locally
git remote add origin https://github.com/your-username/Devops.git
◼️Create a new file in Devops/Git/Day-02.txt & add some content to it.
mkdir -p Devops/Git
echo "Hello , this is Day 02 content!" > Devops/Git/Day-02.txt
git add .
git commit -m "Add dat 02 content"
Push your local commits to the repository on GitHub.
git push -u origin master
Now go to github and see the changes are reflected in repository or not.