Skip to content

Instantly share code, notes, and snippets.

@colormono
Last active March 29, 2019 17:33
Show Gist options
  • Save colormono/fb758f5807e585559a085e39bd7440a7 to your computer and use it in GitHub Desktop.
Save colormono/fb758f5807e585559a085e39bd7440a7 to your computer and use it in GitHub Desktop.
[GIT] Basic Git commands #CLI
# Clone a repository
git clone [email protected]:github-org/github-ce.git
git clone https://github.com/github-org/github-ce.git
# Clone a repository with another profile
git clone [email protected]:github-org/github-ce.git
# Basic Git commands
git checkout <branch_name>
# Download the latest changes in the project
git pull REMOTE NAME-OF-BRANCH
# Delete a Local GIT branch
git branch -d branch_name
git branch -D branch_name
# Delete a remote GIT branch
# git push origin --delete <branch_name>
git push <remote_name> --delete <branch_name>
# Merge created branch with master branch
git checkout NAME-OF-BRANCH
git merge master
# Merge master branch with created branch
git checkout master
git merge NAME-OF-BRANCH
# View the changes you’ve made and differences
git status
git diff
# Stash changes
git stash save "Description"
git stash list
git stash apply stash@{0}
git stash pop
git stash drop stash@{0}
git stash clear
# Add and commit local changes
git add FILE OR FOLDER
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
# Add all changes to commit
git add .
git commit -m "COMMENT TO DESCRIBE THE INTENTION OF THE COMMIT"
# Send changes
# git push origin master
git push REMOTE NAME-OF-BRANCH
# Delete all changes in the Git repository
git checkout .
# Delete all untracked changes in the Git repository
git clean -f
# Unstage all changes that have been added to the staging area
git reset .
# Undo most recent commit
git reset HEAD~1
# View your remote repositories
git remote -v
# Add your Git username and set your email
git config --global user.name "YOUR_USERNAME"
git config --global user.name
git config --global user.email "[email protected]"
git config --global user.email
# Check your information
git config --global --list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment