feat: git commands and stuff

mikcomikco
2 min read
essential commandsdescription
git checkout mainupdate local main branch from remote#1
git fetch origin mainupdate local main branch from remote#2
git rebase origin/mainupdate local main branch from remote#2
(this also works for develop branch just replace main with develop)update local main branch from remote#3
git pull origin —rebaseupdate branch from remote#1
(make sure to click “Update Branch” on PR)update branch from remote#2
git clone <repo link>will clone a repo
git pullwill update local branch and I think with rebase
git add .add all files to staging
git add -uadd all modified files leaving the untracked files
git stashwill save the changes
git stash popwill reflect the latest changes, will be removed from stack
git stash applywill reflect the latest changes, will remain in stack RECOM
git commit -m “<message>“commit changes and preparation to push to remote
git push --set-upstream originpush to head
git push origin <main or develop> <branch>will create a PR
git push origin —forcewill push to head disregarding the commit flow, kinda bad for history tracking but sometimes necessary, just be careful
git merge <branch>will merge <branch> to currently checked out branch (will create a commit which is good)
git logsee what the previous commits of current branch
git reset —soft <commit hash>safe way to reset changes, will restore changes
git reset —hard <commit hash>hard core way to reset changes, good bye changes
git reflogverbose git log
git statussee what files you’ve been working on
git checkout -b <branch>create new local branch with checkout
git checkout <branch>checkout to specified branch
git checkout -checkout previously checkout branch
— i will add more —- i said I will add more —
0
Subscribe to my newsletter

Read articles from mikco directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

mikco
mikco