Skip to content

Instantly share code, notes, and snippets.

@viruskizz
Last active May 7, 2022 16:06
Show Gist options
  • Save viruskizz/b7bb71fe4d1a072735b1a71edd6bf71a to your computer and use it in GitHub Desktop.
Save viruskizz/b7bb71fe4d1a072735b1a71edd6bf71a to your computer and use it in GitHub Desktop.
Basic git commands
## Get starting use git
# create git from empty
git init
# download project into your directory
git clone <url>
git clone <url> <dirname> #rename default project as you wish
## STATUS
# Check your git status
git status
# Check you histories
git log
git log --all --decorate --oneline --graph # fancy logs
## WORK with LOCAL
# Add your file to staging (prepare state)
git add <filename> # add single file or use wildcards to add multiple file
git add . # add all file in current directory
# Save staging file to local repo with message description
git commit -m "message"
## BRANCH
# Check existed branches
git branch #check in local repo
git branch <branch_name> # new branch
# Switch between branch
git checkout <branch_name>
## MERGE
# merge destination to current branch
git merge <dest_branch>
## WORK with REMOTE
# first setup remote repo to url
git remote add origin <url>
# Push your current state in local repo to remote repo
git push origin <branch_name>
# Download and merge all current code current version from remote to local
git pull origin <branch_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment