feat: git commands and stuff
mikco
2 min read
essential commands | description |
git checkout main | update local main branch from remote#1 |
git fetch origin main | update local main branch from remote#2 |
git rebase origin/main | update 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 —rebase | update 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 pull | will update local branch and I think with rebase |
git add . | add all files to staging |
git add -u | add all modified files leaving the untracked files |
git stash | will save the changes |
git stash pop | will reflect the latest changes, will be removed from stack |
git stash apply | will 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 origin | push to head |
git push origin <main or develop> <branch> | will create a PR |
git push origin —force | will 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 log | see 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 reflog | verbose git log |
git status | see 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