Git
Git is a powerful version control system which used to manage the code across multiple users and track changes across different versions.
Installation:
Download and install GIT from the below path
https://git-scm.com/download/win
Once installed, Git can be used as a version control system through various commands.
You can configure Git for a specific folder on your computer, allowing you to manage all changes to existing files and the addition of new files within that folder
Basic commands:
1. git init:
This will initialize new repository in the current directory. This also creates .git directory and store all version control information.
2. git config:
git config --global user.name "Ranjith "
git config --global user.mail "ranjith201099@gmail.com"
3. git status
Shows the current status of working area like staged, untracked and unstaged.
4. git add
add changes from working directory to the staging area, preparing them to commit.
To add specific file: git add "filename.py"
To add all changes git add .
5. git commit
git commit -m "<message>"
Commits the staged changes with descriptive mesage
6. git log
Displays the list of commit history for the repository.
It will show commit id, author, dates and commit changes
Creating a branch
git branch <branch_name> - to create branch
git checkout <branch_name> - to switch to the new branch
git branch -b <branch_name>
to create and switch to branch
git branch - to view all the branches (current branch will be highlighted with asterisk)
Merge a branch:
Once completed work on a branch and want to integrate it into another branch (like master), merging comes to place.
It means all the changes we have made in <branch_name> will be merged with master branch.
First, switch to the branch you want to merge into: git checkout master
Then, use git merge <branch_name> to merge your branch.
Deleting branch
Once the code changes in <branch_name> merged into <master> branch, we might need to delete branch.
use git branch -d <branch_name> to delete branch