Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 1.1 KB

git.md

File metadata and controls

69 lines (45 loc) · 1.1 KB

git cheat sheet

Helpful git fixes: https://ohshitgit.com/

Debugging

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git …

clone

git clone https://host/path/to/repo [location]
git clone ssh://<user>@<hostname>:<port>/path/to/repo.git [location]

checkout branch

git checkout -b <local-name> <remote>/<remote-name>
git checkout -t -b <local-name> <remote>/<remote-name>  # Check out and set up tracking

push to a given remote

git push <remote> <local-name>
git push <remote> <local-name>:<remote-name>
git push -u <remote> <local-name>:<remote-name>  # Set up tracking for the local repo

add/update commit with different permissions

git update-index --chmod=(-|+)x <file>

Remove staged and working directory changes

git reset --hard

Reset single file

git checkout -- <file>

Getting info on a repo

git ls-remote --heads <git-url>
git ls-remote --tags <git-url>

Undo/redo unpushed commit

git reset HEAD~   # undo commit, but don't touch working tree
# do changes
git commit -c ORIG_HEAD