Git Cheat Sheet

Various commands I keep forgetting related to Git.

Tags

List all tags with git tag:

$ git tag
0.0.1
0.0.2
0.0.3
0.0.4
0.0.5
0.0.6
0.0.7
0.0.8
$

Delete all tags on remote with git tag | xargs -L1 git push --delete origin:

$ git tag | xargs -L1 git push --delete origin
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.1
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.2
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.3
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.4
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.5
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.6
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.7
To github.com:andrewcole/example-repository.git
 - [deleted]         0.0.8
$

Delete all tags locally with git tag | xargs -L1 git tag --delete:

$ git tag | xargs -L1 git tag --delete
Deleted tag '0.0.1' (was 3560259)
Deleted tag '0.0.2' (was 9b38a73)
Deleted tag '0.0.3' (was 20b2ac5)
Deleted tag '0.0.4' (was 36d771c)
Deleted tag '0.0.5' (was a96563c)
Deleted tag '0.0.6' (was 2c86d72)
Deleted tag '0.0.7' (was 71efbae)
Deleted tag '0.0.8' (was 10764d8)
$

Branches

Checkout a remote branch into the local working copy with git checkout -t remote/branch:

$ git checkout -t remote/branch
Branch 'branch' set up to track remote branch 'branch' from 'origin'.
Switched to a new branch 'branch'
$

References

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *