Skip to content

Instantly share code, notes, and snippets.

@seanwolter
Last active December 15, 2015 10:29
Show Gist options
  • Save seanwolter/5246286 to your computer and use it in GitHub Desktop.
Save seanwolter/5246286 to your computer and use it in GitHub Desktop.
git stuff I always forget
-------clone a project locally
git clone --recursive [email protected]:seanwolter/the_project_goes_here.git
-------push back to github:
git push origin master
-------add upstream to my repo
git remote add upstream [email protected]:vokalinteractive/the_project_goes_here.git
-------get back to an older commit
# reset the index to the desired tree
git reset 56e05fced
# move the branch pointer back to the previous HEAD
git reset --soft HEAD@{1}
git commit -m "Revert to 56e05fced"
# Update working copy to reflect the new commit
git reset --hard
-------delete current changes, return to last commit
git reset --hard
-------make a more recent branch the master
git checkout better_branch
git merge --strategy=ours --no-commit master
git commit #add your commit message
git checkout master
git merge better_branch
--------add a submodule
git submodule add https://github.com/tonymillion/Reachability.git Lib/Reachability
--------remove a submodule for real
http://stackoverflow.com/questions/1260748/how-do-i-remove-a-git-submodule
1. Delete the relevant section from the .gitmodules file.
2. Delete the relevant section from .git/config.
3. Run git rm --cached path_to_submodule (no trailing slash).
4. Commit and delete the now untracked submodule files.
--------delete tags locally and on Github
1) Delete the v0.4 tag locally: git tag -d v0.4

2) Delete the v0.4 tag on GitHub (which removes its download link): git push origin :v04.

3) Add a new tag for the newest stable release: git tag -a v0.5 -m "Version 0.5 Stabl"

4) Push the latest tag to GitHub (two dashes): git push --tags
--------push to a different remote branch
git push remote local_branch:remote_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment