Table of contents
No headings in the article.
What is Git and why is it important?
Git is a version control system, which is used to track all the changes that are made to a particular file. Let's say if someone deleted the file, git will be able to revert the changes back to original, because git will store all the information of the file like time, version, author everything, which make git very important in daily life.
What is the difference Between Main Branch and Master Branch??
There is no difference. In the past ‘master’ was the typical default branch in a git repo and it is replaced with ‘main’ more recently. They are both simply branches and one or the other is likely to be default branch
Can you explain the difference between Git and GitHub?
Git is version control system that controls and gives us compelet information about the files
GitHub is a source code repository, where the developers store their code
To integrate all the developers source code at one place we will use Source Code Repository Softwares
How do you create a new repository on GitHub?
Login to github https://github.com/
Click on the profile icon on top right-hand side of the page
click on your repositories and click on new
Give a repository name and click on the create
What is difference between local & remote repository? How to connect local to remote?
Local repositories are the one that are from your local computer whereas the remote repositories are from remote machines like servers where all the data is stored and provided to the team.
To connect to local to remote, we need to make use of git commands
Create a Repo in the github and use the git commands
git init
git add .
git status
git commit -m "comments any"
git branch -M main
git remote add origin "url of the newly created repo"
git push -u origin main
Task 1 : Set your user name and email address, which will be associated with your commits.
Login to VM and install git (Ubuntu)
sudo apt install git
git config --global user.name "rjthapaa"
git config --global user.email "rjthapaa@gmail.com
Task 2:
Create a repository named "Devops" on GitHub
login to github and click on new icon (top left of page), give a name as Devops and click on new repository
DevOps repo is created now
Connect your local repository to the repository on GitHub.
Download and install Git
Open git bash from the local and use git commands to add and push the content to the repo in Github
Create a new file in Devops/Git/Day-02.txt & add some content to it
mkdir Devops/Git
cd Devops/Git
echo "Write your content">File.txt
Push your local commits to the repository on GitHub
Git commands from the created repo called DevOps
git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/rjthapaa/Devops.git git push -u origin main
We have successfully pushed a file from the local repo to GitHub