Skip to content

Instantly share code, notes, and snippets.

@wpjerrykwok
Last active January 3, 2024 22:13
Show Gist options
  • Save wpjerrykwok/b0d8295275441cc194db4c08a513b7d9 to your computer and use it in GitHub Desktop.
Save wpjerrykwok/b0d8295275441cc194db4c08a513b7d9 to your computer and use it in GitHub Desktop.
Git notes

copy repo from GitHub git clone <URL>

stage the file git add.

check file status git status

commit the file git commit -m "msg" -m "more desc"

commit an existing file git commit -am "msg"

make GitHub same as local git push origin main

set the origin main as default git push -u origin main git push

make a local folder a repo git init

link to a remote site git remote add origin <URL>

show the remote site list git remote -v

add a branch from main @main git switch -c <name>

list branch git branch

check the diff btw branch git diff <branch name>

merge branch to main @main git merge <branch name>

create a pull request git pull

delete a branch git branch -d <branch name>

keep local branch updated to main git merge main

undo a add (the edits stay) git reset

undo a commit step (the edits stay) git reset HEAD~1

undo a certain commit (the edits stay) git reset <hash>

undo a certain commit (get rid of edits) git reset --hard <hash>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment