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.
Git installed locally on a system.
A software tool.
A licensed open-source tool.
GitHub Hosted on the web.
A service tool.
A pay-for-use tier
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.
There are two main types of version control systems:
Centralized version control systems (CVSS)
Distributed version control systems. (DVSS)
CVCS uses a central server to store all the versions of a project's files.
DVCS allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later
Initialize a local repository
git init <directory>
Set configuration value for your username and email
git config --global user.name <your name>
git config --global user.email <your email>
Clone a repository
git clone <repository-url>
Add a file to the staging area
git add <file>
Add all file changes to the staging area
git add .
Check the unstaged changes
git diff
Commit the staged changes
git commit -m "Your Message"
Reset the staging area from the last commit
git reset <file>
Check the status of the working directory
git status
Remove a file from the index and working directory
git rm <file>
List the commit history
git log
Branch is a new/separate version of the main repository.
To display branches
git branch
To create a branch
git branch <branch name>
To switch to a branch
git checkout <branch name>
To delete a branch
git branch -d <branch name>
To merge a branch
git merge <branch name>
Pull changes from a remote repository
git pull <remote name>
Push changes to a remote repository
git push <remote> <branch-name>
Push a branch into a remote repository
git push origin master
Rebasing is the process of moving or combining a sequence of commits to a new base commit.
git rebase <branch name>
Git cherry-pick is a command that allows you to select specific commits from one branch and apply them to another.
This can be useful when you want to selectively apply changes that were made in one branch to another.
git cherry-pick <branch name>
Git is used to track changes in the source code, enabling multiple developers to work together on non-linear development.
Learning is a continuous process and one of the best ways to learn is to practice, as the challenges faced will educate and prepare you for the next phase of your journey.
Kindly share your feedback in the comment section, thank you for reading and see you at the next one...