Skip to content

jbranchaud/man-git

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 

Repository files navigation

man-git

a collection of git tips and tricks

Tips and Tricks (by command)

git branch

Delete a local branch

git branch -d <branch-name>

source

Delete an unmerged local branch

git branch -D <branch-name>

source: git man pages

git checkout

Checkout specific file from another branch

git checkout <branch_name> -- <paths>

source

git diff

Show the files and changes that have been staged

git diff --cached

source

Show the difference between two (local) branches

# diff to show what is in branch-2 that is not in branch-1 (..)
git diff branch-1..branch-2

# diff to show what is in branch-1 that is not in branch-2 (..)
git diff branch-2..branch-1

# diff based on the common ancestor of branch-1 and branch-2 (...)
git diff branch-1...branch-2

source

# list only the names of the files
git diff branch-1..branch-2 --name-only

source

# list the status and name of each file
git diff branch-1..branch-2 --name-status

source

git push

Delete a remote branch

git push origin --delete <branch-name>

source

git remote

Change/Update the remote repository URL

git remote set-url <remote-name> <remote-url>

# for example, change origin url to github.com/user/repo-name
git remote set-url origin https://github.com/user/repo-name.git

source

git reset

Squash some commits

# move the head back two commits as the contents of those
# two commits gets squashed onto the index
git reset --soft HEAD~2
# commit the now squashed changes
git commit

source

git tag

Delete a remote git tag

git tag -d v1.0.0
git push origin :refs/tags/v1.0.0

source

Links (by command)

git fetch

git ls-files

List all files staged for deletion (and then do something with them)

# simply list the files staged for deletion
git ls-files --deleted -z

# perform a `git rm` on the files, putting them on the index
git ls-files --deleted -z | xargs -0 git rm

# perform a `git checkout --` on the files, unstaging them
git ls-files --deleted -z | xargs -0 git checkout --

source

git pull

git reset

Resources

Commit Messages

Tools

  • hub - hub helps you win at git
  • git-extras - little git extras
  • gitfs - version controlled file system
  • elastic-git - Store data in git, find it in Elasticsearch

Workflows

License

© 2015 Josh Branchaud

This repository is licensed under the MIT license (see LICENSE for details).

About

a collection of git tips, tricks, and resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published