Basic Git Commands for Beginners

CommandTask
git initTo Initialize a Repository
git add <file name>To add a single file
git add .To add all files to the Repository
git statusTo view a status
git commit -m "type you message here"To commit with a message
git clone <repourl>To clone the repo
git pullTo pull the changes to a local repository
git pushTo push the local changes to a remote repository
git branch <name of the branch>To create a new branch
git branchTo see available branches
git checkout <name of the branch>To switch branch
git branch -b <name of the branch>To create and checkout into that branch
git switch <name of the branch>To switch branch
git switch -To switch to the previous branch
git switch -c <name of the branch>To create and switch to the branch
git logTo view over all history of the project
git remote add origin <url>To add personal url or repo to local
git remote add upstream <url>To add upstream url or repo to local
git push origin <branch name> -fTo force push commits
git fetch --all --pruneTo fetch changes
git reset --hard upstream/mainTo reset the main branch of the origin to the main branch of upstream
git pull upstream mainTo reset main branch of the origin to the main branch of upstream
git rebase -i <git log code>squashing commits
git reset --hard HEAD^To remove the last commit

Did you find this article valuable?

Support Vinay Hirgond by becoming a sponsor. Any amount is appreciated!