Member-only story
An easy way to understand GIT
Intermediate git commands and their meanings explained
I have been using GIT for versioning my work repositories as many programmers and I wanted to make a review for the most used commands and their logic to have a deeper understanding. Here is a collection that I have made after some online tutorials and classes that I would like to share with you!
- Create a new branch
git branch new_branch_name
(or
git checkout new_branch_namegit switch new_branch_name
) orgit checkout -b new_branch_name
orgit switch -c new_branch_name
2. Create a new branch with an old commit to continue working from there
git log (to check the commit id)
git checkout id (to pass related commit)
git checkout -b new_branch_name commit_id (create a new branch with that commit)
3. Stage mechanism
You have files that you staged already (that are in your track zone), and you have some changes in these files that you didn’t stage and you wanna delete.
git restore filename
orgit checkout filename
to delete the changes in a specific file
and
git restore .
or