Skip to main content

Command Palette

Search for a command to run...

Git cheatsheet

Updated
1 min read
Git cheatsheet
A

I am a self-motivated and experienced python developer along with skills in the frontend, backend, DevOps, and other technologies. Always wanted to learn new skills and explore technologies.

This post is a tribute to all the knowledge and experience I have gained in using Git, a version control system, and contains valuable code references based on what I have learned over time. It serves as a compilation of my learning journey, and I hope it can be helpful to others who are also exploring the world of Git and coding.

To initialize the repo.

git init

Working with Branch.

Creating a new branch

git checkout -b branch_name
git pull
git push --set-upstream origin branch_name

Creating a new branch from the current branch.

git checkout current_branch
git checkout -b new_branch current_branch
git push origin new_branch

Deleting branch locally.

git branch -d branchname

Deleting the branch on the remote repository.

git push origin --delete remoteBranchName

Git ignore

Adding a file, folder to ignore using .gitignore file.

Removing previously added files.

Add a file name to remove from git repo in .gitignore file then run the command mentioned below.

git rm --cached file_name.txt