Skip to content

Instantly share code, notes, and snippets.

@baskeboler
Created August 27, 2021 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskeboler/2915a779367707b62cd30102c9992698 to your computer and use it in GitHub Desktop.
Save baskeboler/2915a779367707b62cd30102c9992698 to your computer and use it in GitHub Desktop.
basic git cli commands
# create repository
git init
# status
git status
# add a remote called origin with url http://somegit.com/repo/myrepo.git
git remote add origin http://somegit.com/repo/myrepo.git
# stage files
git add file1.txt file2.txt
# commit files
# opens up an editor to add a comment
git commit
# include the commit message in the command
git commit -m "this is the commit message"
# create a new branch called new-branch
git checkout -b new-branch
# push new branch to remote
git push origin new-branch
# merge commits from other-branch into new-branch (the currently checked out branch)
git merge other-branch
# stash uncommitted changes
git stash
# recover stashed changes
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment