This blog Explain about Git
Git is a distributed version control system used for tracking changes in source code during software development. It is widely used by developers to collaborate on projects, manage codebases, and track the history of changes in a code repository. Here are some key concepts and commands related to Git
How to install Git?
Sudo apt udate
sudo apt install git
How to check the version of Git?
git –version
Setting up Git:
git config –global user.name “Your Name”
git config –global user.email youremail@domain.com
Git clone:
(Before git clone create one folder after git clone that folder) The git clone command is used to create a copy of a specific repository or branch within a repository. When you clone a repo, you get a copy of the entire history of the repo.
git clone <repository-link>
What is git status:
The git status commend is used to display the state of the repository and staging area. It allows us to see the tracked, untracked files and changes. This command will not show any commit records or information.
What is git add file_name or git add .?
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
What is git commit -m “message”?
The git commit command captures a snapshot of the project’s currently staged changes. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.
What is git push or git push origin <Branch Name>?
The git push command is used to upload local repository content to a remote repository.
When you push changes, you send the committed changes in your local repository to the remote repository on GitHub. If you change your project locally and want other people to have access to the changes, you must push the changes to GitHub.
How to create new branch in git?
The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch. Once created you can then use git checkout new_branch to switch to that branch.
What is git checkout?
The git checkout command lets you navigate between the branches created by git branch
What is git merge?
Git merge will combine multiple sequences of commits into one unified history. In the most frequent use cases, git merge is used to combine two branches.
Git rebase:
Git rebase is a command in the Git version control system that allows you to integrate changes from one branch onto another branch. It is used to combine a sequence of commits from one branch onto another branch, effectively rewriting the commit history. Syntax: git rebase <from branch> <to branch>
Image referred from geeksforgeeks
Git cherry-pick:
Git cherry-pick is a command in the Git version control system that allows you to select and apply specific commits from one branch onto another branch. It enables you to pick individual commits and apply them to a different branch, essentially replicating those changes on the target branch.
Syntax: git cherry-pick <commit id>
Image referred from geekhunter.com
Fork :
gitHub to gitLab
step 1: git remote add upstream <https://github.com/user/repo>
step 2: git pull upstream master
step 3: git push origin master
Prepared By: Vijayaragavan Nandagopal