What is Git?
Git is a so-called distributed version control system. It helps developers work on the same source code, without
creating problems like code conflicts caused by contradicting changes. Git makes it easy for everyone to see who
modified some code, when, and why. It makes it easy to track what code is written for version 1.1 of the app, and
what changed in version 1.2. It lets people see what lines of code some bug fixes changed, and so on. Long story
short, Git allows multiple people to collaborate on the same source code.
Learn about Git
You can learn more about Git by reading the DevOps: Git for Beginners blog. That way you get a quick intro. If
you have time to learn more though, we recommend the KodeKloud. This explains the basic concepts of Git such as
branching, merging, rebasing, reverting, etc. It includes visualizations and animations for a better understanding
of the concepts. The learners also get access to the labs where they can get practical experience with Git.
Play with Git
Experiment with Git as much as you’d like by using this Git playground. The playground includes the
git command preinstalled. You also get access to Gitea, something that will let you access a
website similar to GitHub. It's basically a self-hosted web platform that lets you store source code in
repositories, and perform various actions on it, through your web browser. But the git command can also interact
with the Gitea service (for example, to upload new code from a local computer to a Gitea repository).
Basic Git commands
- Initialize an empty repository
git init
- To check the status of the repository
git status
- Add the untracked files in the staging area. We basically tell Git what files we intend to update with our next commit action.
git add <file_names>
- To save the changes to the local repository
git commit -m “Message to describe the commit”
- To create, delete or list the branches in the repository
git branch <branch_name> (Creates branch)
- To switch from one branch to another
git checkout <branch_name>
- To integrate the working branch with stable or other branches
git merge <branch_name>
- To create a copy of the repository in a local machine
git clone <repository_url>", 'instruction' => "
Git Playground
Welcome to the Git playground! This environment allows you to practice and explore Git commands.
Username: mcdns Passowrd: mcdns123
Click the Red Cross button on the top right corner to end this sandbox environment
Basic Commands:
Git Version Check
Git Version Check
git --version
Configure Git:
# Set your name
git config --global user.name 'Your Name'
# Set your email
git config --global user.email 'your.email@example.com'
# Initialize a new repository
git init
# Clone an existing repository
git clone <repository-url>
# Check the status of your repository
git status
# Stage changes for commit
git add <file-name>
# Commit changes
git commit -m 'Your commit message'
Feel free to explore and practice different Git commands. Happy coding!