Last active
May 29, 2019 01:36
-
-
Save Bahaaib/9820d2afe4604d05353ede4bef24565d to your computer and use it in GitHub Desktop.
Important git commands
This file contains hidden or 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
| ##Fetch changes from remote repository to local machine | |
| #Reference a remote repository locally under name 'upstream' | |
| - git remote add upstream <link> | |
| #De-reference a remote repository locally under name 'upstream' | |
| - git remote rm upstream | |
| #Fetch the new changes from upstream | |
| - git fetch upstream | |
| #Merge the fetched changes to the local cloned repository at master branch | |
| - git merge upstream/master | |
| #Push the most recent version of your local repository to the remote one on on Github | |
| - git push | |
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| ##Handling git credentials | |
| #Save git credentials (Username && Password) locally to avoid entering them on every push | |
| - git config --global credential.helper store | |
| #Setting Username && Password to start a connection to your Github account | |
| - git config --global user.name "myUsername" | |
| - git config --global user.email "mail@domain.com" | |
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| ##Creating a new local repository | |
| #Initializing a new empty repository | |
| - git init | |
| #Checking your repository status upon every change | |
| - git status | |
| ##Staging files | |
| #Add new single file to local repository | |
| - git add <file-name> | |
| #Add new multiple files to local repository | |
| - git add <file1> <file2> <file3> | |
| #Add all changed files at once | |
| - git add --all | |
| #Remove file from local repository | |
| - git reset <file-name> | |
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| ##Commit staged (changed) files | |
| #Set the commit message | |
| - git commit -m "commit message" | |
| #Commit with message at once | |
| - git -a -m "commit message" | |
| #Undo the most recent commit | |
| - git reset --soft HEAD^ | |
| #Replace the most recent commit with another commit | |
| - git commit --amend -m "commit message" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment