GitCheatsheet

Table of Contents

Cheatsheet

  • Reverting changes to modified files
    • git reset --hard
  • Removing a remote branch
    • git push origin --delete my-branch

Creating A New Remote For A Local Repo

This process is used when:

  1. You have code on your local machine that is in a git repo.
  2. This code is not currently pushed to a remote.
  3. You want to store a remote on a different filesystem (e.g. a directory accessible over NFS or SSH).

In this example I'm pushing to a shared Windows drive.

# Navigate to the location of where you want to store your code.
cd \\some-server\share$\tom\git
git init --bare dotemacs

# Now navigate to your repo and push
cd c:\users\tom\.emacs
git remote add origin '\\some-server\share$\tom\git\dotemacs'
git push --set-upstream origin master
git push origin --mirror

Now you can backup your repo to a different server and even share your code with others who have access to that shared directory.

  • This is a very long line this is a very long line this is a very long line this is a

View Pull Request Diff From The Command Line

cd $project
git checkout $trunk
git pull
git checkout $feature_branch
git pull
git request-pull dev ./
# If you want to see the diff contents add the -b flag

Last Updated .