Git - pxlshpr/knowledge-base GitHub Wiki
Command | Comments |
---|---|
git fetch |
git fetch just "downloads" the changes from the remote to your local repository. |
git pull |
git pull downloads the changes and merges them into your current branch, making it a fetch + merge .Always pull after committing. |
git ls-remote |
List all references (branches and heads) along with the SHA1 of their latest commits. |
Command | Comments |
---|---|
git branch |
List branches (the asterisk denotes the current branch) |
git branch -a |
List all branches (local and remote) |
git checkout -b |
Create a branch and switch to it at the same time. |
git checkout master |
Merge a branch into master. |
git push -d origin |
Delete a remote branch |
git branch -d |
Delete a local branch |
Command | Comments |
---|---|
git rm -r --cached |
Forget a folder (or file) that had been committed earlier. |
git reset --hard |
Revert repo to a previous commit |
Command | Comments |
---|---|
git tag 0.1 |
Tag the last commit and push the tag(s). |
git tag -d 0.1 |
Delete a tag and push the change. |
git tag |
List local tags. |
git ls-remote --tags origin |
List remote tags on origin. |
Command | Comments |
---|---|
git archive --format zip --output /full/path/to/zipfile.zip |
Export a zip archive of a specific commit. |