Last active
April 10, 2020 13:21
-
-
Save davidisnotnull/6b7b4ed7855bf742f7e9bf9da57aa74b to your computer and use it in GitHub Desktop.
Useful 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
# Stages all uncommited files to local | |
git add -A | |
# Adds a commit message to the local staged files | |
git commit -m "Commit message" | |
# Pushes the locally staged files to the remote repo | |
git push origin | |
# Cleans up local branches from the remote | |
git fetch origin --prune | |
# Set the global git user name. Remove global to apply to a local repo | |
git config --global user.name "Mona Lisa" | |
# Set the global git email address. Remote global to apply to a local repo. | |
git config --global user.email "[email protected]" | |
# Stores the current branch changes | |
git stash | |
# Shows a list of stashed changes | |
git stash list | |
# Returns the stashed changes to the codebase | |
git stash apply | |
# Exports a repo to a zip file, stripping out all git related files) | |
git archive --format zip --output /full/path/to/zipfile.zip master | |
# Pushed your repo to another repository (ideally a blank one) | |
git push --mirror https://url.ofyour.otherrepo | |
# Merge Project A into Project B | |
cd path/to/project-b (On local file system) | |
git remote add project-a path/to/project-a (Use git clone URL) | |
git fetch project-a --tags | |
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge | |
git remote remove project-a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment