Git - pxlshpr/knowledge-base GitHub Wiki

Git

Sections

  1. Basics
  2. Branching
  3. Making Changes
  4. Tagging
  5. Exporting

1. Basics

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.

2. Branching

Command Comments
git branch
List branches (the asterisk denotes the current branch)
git branch -a
List all branches (local and remote)
git checkout -b <branch>
git push -u origin <branch>
Create a branch and switch to it at the same time.
git checkout master
git pull
git pull origin <branch>
git push
Merge a branch into master.
git push -d origin <branch>
Delete a remote branch
git branch -d <branch>
Delete a local branch

3. Making Changes

Command Comments
git rm -r --cached <folder>
git commit -a -m "Removes <folder>"
Forget a folder (or file) that had been committed earlier.
git reset --hard <commit_hash>
Revert repo to a previous commit

4. Tagging

Command Comments
git tag 0.1
git push --tags"
Tag the last commit and push the tag(s).
git tag -d 0.1
git push origin :0.1"
Delete a tag and push the change.
git tag
List local tags.
git ls-remote --tags origin
List remote tags on origin.

5. Exporting

Command Comments
git archive --format zip --output /full/path/to/zipfile.zip <commit_hash>
Export a zip archive of a specific commit.
⚠️ **GitHub.com Fallback** ⚠️