blog image

Basic Git command


git init
git add .
git add file_name.extension
git commit -m "commit message"
git push origin branch_name

Branch  related command

git branch branch_name_to_create
git checkout branch_name_to_switch


git checkout -b branch_name_to_create # This will create a new branch and switch to it.

git branch -m new_name_to_branch (for rename)


git branch -d branch_name  # Safe delete
# or
git branch -D branch_name  # Force delete


# Deleting a remote branch
# Push a delete request to the remote repository:

git push origin --delete branch_name

 

Other commands 

git log

git revert  <commit_hash>
git stash
git stash pop


git checkout --orphan Day2
#This will create a new branch without any history from the current branch.
# The --orphan option creates a new branch with no commit history, essentially making it a blank # slate

git rm -rf .
#Since the new branch still has the files from the working directory, you need to remove them. This # won't affect the main branch. it removes all tracked files from the index, preparing the branch to # be entirely new content

 


About author

author image

Amrit Panta

Python developer, content writer



3 Comments

Amanda Martines 5 days ago

Exercitation photo booth stumptown tote bag Banksy, elit small batch freegan sed. Craft beer elit seitan exercitation, photo booth et 8-bit kale chips proident chillwave deep v laborum. Aliquip veniam delectus, Marfa eiusmod Pinterest in do umami readymade swag. Selfies iPhone Kickstarter, drinking vinegar jean.

Reply

Baltej Singh 5 days ago

Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Marie Johnson 5 days ago

Kickstarter seitan retro. Drinking vinegar stumptown yr pop-up artisan sunt. Deep v cliche lomo biodiesel Neutra selfies. Shorts fixie consequat flexitarian four loko tempor duis single-origin coffee. Banksy, elit small.

Reply

Leave a Reply

Scroll to Top