Last active
April 17, 2021 09:22
-
-
Save andineck/7579028 to your computer and use it in GitHub Desktop.
random git notes
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
http://git-scm.com/ | |
http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging | |
http://ndpsoftware.com/git-cheatsheet.html | |
https://help.github.com/articles/fork-a-repo | |
git status | |
git clean | |
git reset | |
git clean -f | |
# http://stackoverflow.com/questions/1146973/how-to-revert-all-local-changes-in-a-git-managed-project-to-previous-state | |
# will remove untracked files | |
git reset --hard HEAD | |
git clean -f -d | |
git pull | |
-- | |
# clone | |
git clone https://github.com/visionmedia/express.git | |
-- | |
# create github repo | |
curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}' | |
# Remember replace USER with your username and REPO with your repository/application name! | |
git remote add origin [email protected]:USER/REPO.git | |
git push origin master | |
--. | |
# switch branch | |
git checkout origin/mobile | |
git config --global core.editor nano // nano als standard editor | |
git tag // lists tags | |
git tag -a v0.10 // adds the tag with a note -> the editor will open to enter the note | |
git tag -a v0.10 -m "Version 0.5 Stable" // adds the tag with the note directly (without text editor) | |
git tag -d v0.10 // deletes the tag | |
git push --tags // push the tag to the remote repository | |
git push origin :v0.10 // deletes the remote tag, when deleted locally before with: git tag -d v0.10 | |
git pull origin simplify // pull from the simplify branch | |
git push origin simplify // push to the simplify branch | |
git checkout v0.2 | |
---- | |
git pull # is needed in order to get the tags. git pull origin … does not get the tags | |
# falls auf einem branch Änderungen gemacht wurden, evtl. geänderte Dateien von hand löschen, oder | |
git reset --hard HEAD | |
git clean -f -d | |
git pull | |
git checkout v0.2 | |
--- | |
Fork and Merge | |
https://help.github.com/articles/fork-a-repo | |
https://help.github.com/articles/merging-branches | |
Merging from fork origin (upstream): https://help.github.com/articles/syncing-a-fork | |
git remote add upstream https://github.com/otheruser/repo.git | |
git remote -v | |
git fetch upstream | |
git branch -va | |
git checkout master | |
git merge upstream/master | |
--- | |
# Manual: https://help.github.com/articles/fork-a-repo | |
# Note: git pull = git fetch && git merge | |
# 0. install diffmerge with the installer | |
# set as default mergetool | |
git config --global merge.tool diffmerge | |
# 1. fork and clone with github web interface and github app: | |
# 2. add original as upstream | |
git remote add upstream https://github.com/MatthewMueller/cheerio.git | |
git fetch upstream | |
# 3. add another fork for merging reasons or so | |
git remote add rafaelrinaldi https://github.com/rafaelrinaldi/cheerio.git | |
git fetch rafaelrinaldi data-support | |
# * branch data-support -> FETCH_HEAD | |
git mergetool FETCH_HEAD | |
# if merge was not successful and you want to discard all changes: RESET git and proceed with 3. | |
git reset --hard HEAD | |
git clean -f -d | |
# other notes | |
git checkout master | |
git pull upstream master # assuming "upstream" is your alias for MatthewMueller/cheerio | |
git checkout data-support | |
git pull --rebase . master | |
# resolve any merge conflicts | |
git push origin data-support --force # update your remote branch (and this pull request) | |
# rebase | |
git checkout develop | |
git pull | |
git checkout myfeaturebranch | |
git rebase -i develop | |
# fix merge conflicts manually (add fixed files) | |
git rebase --continue | |
git push -f | |
# delete all local branches that are merged to master or develop | |
git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d | |
# checkout file from other branch | |
git checkout mybranch -- index.js | |
# git compare file with other branch | |
git diff master:index.js mybranch:index.js | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment