Skip to content

Instantly share code, notes, and snippets.

@kklecho
Last active April 6, 2021 16:46
Show Gist options
  • Save kklecho/cd62e8604d49a0127981f6816ac93cac to your computer and use it in GitHub Desktop.
Save kklecho/cd62e8604d49a0127981f6816ac93cac to your computer and use it in GitHub Desktop.
common git commands
git init
git add .
git commit -m "Initial commit"
# now create repo in github or elsewhere, get it's url and run below
git remote add origin <url_or_ssh>
# check
git remote -v
# push
git push origin master
## branches
# list
branch
# create new on working code & switch to it right away
git checkout -b <branchname>
# just create
git branch <branchname>
# just switch
git checkout <branchname>
# publish local branch to repo
git checkout <branchname>
git push origin <branchname>
# Merge from parent (e.g. dev) branch to child (e.g. feature) branch:
# 1. checkout to feature branch
# 2. merge (-no-ff brings commits from parent) :
git merge --no-ff <parent_branch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment