Skip to content

Instantly share code, notes, and snippets.

@stephane777
Last active May 10, 2020 15:17
Show Gist options
  • Select an option

  • Save stephane777/13be5e4fedacf00f03d38e90325f2dbd to your computer and use it in GitHub Desktop.

Select an option

Save stephane777/13be5e4fedacf00f03d38e90325f2dbd to your computer and use it in GitHub Desktop.
## Git Blobs and trees
### Asking Git for the SHA1
> echo 'Hello, World!' | git hash-object --stdin
8ab686eafeb1f44702738c8b0f24f2567c36da6d
## Git Commits
commit are stored in .git/objects
tree .git/objects
### Print out the type of the commit
git cat-file -f 980a0
blob
### Print out the contents of the commit
git cat-file -p 980a0
Hello World!
## Git Staging
git ls-files -s
git add -P
## Git Stash
#### Stach changes
git statsh
#### list changes
git stash
#### show the contents
git statsh show stash@{0}
####apply the last stash
git statsh apply
#### apply a specific stash
git stash apply stash@{0}
#### remove a stash
git stash drop stash@{0}
### remove all
git stash clear
Stash are visible from all branches !
## Tags
tag is a pointer to a commit
git tag "initial-commit"
list all tags in a repo
git tag
list all tags, and what commit they're pointing to
git show-ref --tags
List all the tags pointing at a commit
git tag --points-at < commit >
Looking at the tag, or tagged contents:
git show < tag-name >
list heads
git show-ref --heads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment