Last active
June 29, 2016 08:10
-
-
Save wwwbruno/4f7b7e3e616ae8187238 to your computer and use it in GitHub Desktop.
Git basic commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HELP | |
git help | |
git help config # get help for config command | |
git help commit # get help for commit command | |
# BASICS | |
git init # starts a new git repo | |
# FILES AND STAGE | |
# status | |
git status # show the modefied files and the files on the stage | |
git diff # show all file's change from the last commit | |
git diff file_name # show the file's change from the last commit | |
git diff --staged # show all file's change on the stage | |
git reset file_name # remove file from stage | |
# add and remove | |
git add file_name # add a file to the stage | |
git add directory # add the directory and all it's file to the stage | |
git checkout -- file_name # discart file's change on stage | |
# commit, pull and push | |
git commit -a -m 'My commit' # add and commit all files in one command | |
git commit -a -m 'My commit' file_name # add and commit the file in one command | |
git commit -m 'My commit' # commit the files in the stage | |
git commit --amend -m 'My commit' # amend (join) the actual stage to the last commit | |
git reset --soft HEAD^ # undo the last commit, but keep the changes | |
git reset --hard HEAD^ # undo the last commit, and discart the changes | |
git push origin master # push the commits to the 'origin' remote in the 'master' branch | |
git push -u origin master # push the commits to the 'origin' remote in the 'master' branch and save it as default remote | |
# REMOTES | |
git remote add origin [email protected]:wwwbruno/example.git # add '[email protected]:wwwbruno/example.git' as 'origin' to the remotes | |
# FILES | |
git log # Show all the commits | |
# CONFIG | |
# config name | |
git config user.name = 'Bruno Almeida' # config user name for the actual repo | |
git config --global user.name = 'Bruno Almeida' # config user name for all the repos | |
# Config email | |
git config user.email = '[email protected]' # config user e-mail for the actual repo | |
git config --global user.email = '[email protected]' # config user e-mail for all the repos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment