Skip to content

Instantly share code, notes, and snippets.

@eduardolfalcao
Last active September 9, 2020 12:47
Show Gist options
  • Save eduardolfalcao/d7e791d85fcb16e0d90e5825b3969ab7 to your computer and use it in GitHub Desktop.
Save eduardolfalcao/d7e791d85fcb16e0d90e5825b3969ab7 to your computer and use it in GitHub Desktop.
#initialize github repo in a dir
git init
#add file or change to versioning
git add <file-path>
#add all files in dir (recursively) to versioning
git add -A
#commit changes locally
git commit -m "message"
#link local repository (origin) with remote; this is made once, on the beginning
git remote add origin <repo-url>
#send local changes to server, to the master branch
git push origin master
#view all branches
git branch -va
#create a new branch with content of current branch
git checkout -b <name-of-branch>
#viewing commit history
git log
#changing the most recent and still not pushed commit
git commit --amend -m "New commit message."
#amending last change to commit without changing message
git commit --amend --no-edit
#removing last commit (including files and all state)
git reset --hard HEAD^
#resetting to old commit
git reset --hard <old-commit-id>
#changing remote repo to new location
git remote set-url origin <git url>
#merge with master
git checkout master
git merge <branch-to-be-merged>
git push origin master
# delete branch locally
git branch -d <local-branch-name>
# delete branch remotely
git push origin --delete <remote-branch-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment