Payilagam Day-06: 20-Feb-2025
Topic: Git Commands: Part-2
Below, we are going to discuss about the remaining git commands for a beginner.
-
git diff <commit_id> <commit_id>
It shows the difference between the two commits with the insertion and deletion information.
-
git branch
The output of this command is a list of branches available in our local repository.
-
git branch <branch_name>
It creates a new branch in our repository.
git checkout
(main -> default branch)
i). git checkout is used to switch between the branches in our local repository.
syntax: git checkout -b new_branch_name
ii). when we create a new branch, git automatically switch the working directory with the latest commits in current branch and point the working directory to the created branch.
iii). after creating the new branch, we can add, modify, delete the files as our wish.
iv). then if we re-checkout to the older branch, it still remains the older version as when the new branch is created.
:WORKFLOW =>
start
=====
branch - description
main - contains 1,2,3.
after checkout with new branch
==============================
new_branch - contains 1,2,3(same as the main branch)
Note: We can modify the new branch as our wish but the changes are only reflect in the new_branch.
after modifying the new branch
==============================
main - contains 1,2,3.
new_branch - contains 1,2,3,4,5,6(modified) => SEE THE DIFFERENCE
Need to discuss again topics:
1. git merge \<branch_name\>
Top comments (0)