Created
October 26, 2018 15:12
-
-
Save kulas/fd481c9823732b4bd2f74a3785e6a689 to your computer and use it in GitHub Desktop.
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
Git Cheat Sheets | |
============== | |
https://devbookhelp.herokuapp.com/git | |
Git Clone | |
============== | |
git clone [repository] [local path] | |
git clone [repository] folder-name | |
git clone [repository] . | |
# If working directory is your desired destination, simply put a "." | |
Branches | |
============== | |
git checkout -b name-of-branch | |
# create new branch and switch to that branch | |
# starts as a copy of the branch you are on | |
# think of this as "branching off of the current branch" | |
git branch my-branchname | |
# creates new branch | |
git checkout branch-name | |
# switch to branch-name | |
*** don’t forget to do this! *** | |
git push -u origin branch-name | |
# push new branch to remote | |
# -u flag is short for --set-upstream | |
git branch -D branch-name | |
# delete the branch | |
Commit | |
============== | |
git add. | |
git commit -m "your message" | |
or | |
git add --all | |
git commit -m "your message" | |
or | |
git commit -a -m "your message" | |
or | |
git commit -am "your message" | |
Fetch, Pull | |
============== | |
git fetch origin | |
# fetches everything merged to origin/master | |
then | |
git pull | |
git pull upstream master | |
# Updating your fork from original repo to keep up with their changes | |
Merge, Rebase | |
============== | |
# https://www.atlassian.com/git/tutorials/merging-vs-rebasing | |
git checkout feature-branch | |
git merge master | |
# Merge master branch into the feature-branch | |
or | |
# Never use rebase on public branches | |
git checkout feature-branch | |
git rebase master | |
# This moves the entire feature-branch into the tip of the master branch | |
# Cleaner project history | |
Other Stuff | |
============== | |
git status | |
# get your git status | |
git stash save --keep-index | |
git stash drop | |
# Remove changes that you do not what to add to the repo | |
git log | |
# opens the git logfile | |
Use "q" to quit | |
Reset a file | |
============== | |
git checkout HEAD -- my-file.txt | |
# this is awesome! | |
.gitignore | |
============== | |
Remove .DS_Store | |
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch | |
Add: .DS_Store to .gitignore | |
Push/Pull | |
============== | |
git push origin branch-name | |
# Pushes the changes in your local repository up to the remote repository you specified as the origin | |
When pushing to a remote, the remote cannot be checked out at that time. | |
git remote add remote-name file-path-to-remote | |
# add my copy of a repository as a remote | |
git pull remote-name master | |
# pull changes from a remote | |
git remote add origin remote-repository-URL | |
# Sets the new remote | |
Pull Requests | |
============== | |
Pull requests are specific to GitHub! I did not know that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment