Git
Resources
- Complete training: https://githubtraining.github.io/training-manual/
- Cheat sheet: https://training.github.com/downloads/github-git-cheat-sheet/
Commands
Compact .git
folder
Reduces the size of the .git
folder by cleaning up cached unuseful thingies.
Bash | |
---|---|
git log
with the cutest formatting
PowerShell | |
---|---|
Push and track a new local branch to a remote repository
PowerShell | |
---|---|
Move existing, uncommitted work to a new branch in Git
List all NON-pushed commits
PowerShell | |
---|---|
Fetch deletion of branches
Deletes the local branches that have been remotely deleted.
Bash | |
---|---|
Delete all tags except one
Example: delete all tags except "2.2.1":
Delete all tags with given prefix
https://gist.github.com/shsteimer/7257245?permalink_comment_id=2623569#gistcomment-2623569
Example: delete all tags with prefix "1.0":
Change upstream branch
This can be useful if you clone
d a repository, then decided to fork it to create a PR.
For example, you clone
d a Github repository "user/some-repo" locally, then decided to edit something to create a PR. First, create a fork in Github (if you have the Github command line tool, you can use gh repo fork --clone --remote --remote-name fork
). This will result in a new repo "yourusername/some-repo". Then run the following inside your working copy: