Skip to content

Instantly share code, notes, and snippets.

@petarjs
Last active October 21, 2015 00:28
Show Gist options
  • Save petarjs/2c6fbbedf5be03ff547d to your computer and use it in GitHub Desktop.
Save petarjs/2c6fbbedf5be03ff547d to your computer and use it in GitHub Desktop.
and commands

General Git

git push origin HEAD - push the current branch to branch with the same name on the server
git push -u origin HEAD - the same, just set upstrem tracking
git remote set-url origin git@github.com:username/repo.git - change the remote
git branch --no-merged - Show branches not merged into master

SSH Keys - Don't ask for password (only works from git bash)

eval $(ssh-agent) # starts the ssh agent on win7, win8
ssh-add /c/Users/Vlada/.ssh/id_rsa # add the key for which you want to disable entering password on every push/pull

Sort branches by relative date

git for-each-ref --sort=-committerdate --format='%(committerdate:relative)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'

Ignore commited files so they don't show as changed/untracked (this only works for files)

git update-index --assume-unchanged <file>
Then if you wanna track changes again
git update-index --no-assume-unchanged <file>

To ignore a whole folder

git rm --cached <file|folder>
then add it to .gitignore
then commit everything
NOTE - when you run git status after git rm --cached, it will show files as deleted, but it doesn't delete them on your disk, just from git.
BUT that means that other people who have those files will LOSE them when they pull!

Visualize git branches

~/git-big-picture ./ -o ~/cl.pdf

NPM without sudo

sudo chown -R $USER /usr/local

Git - estimate time spent on project

git hours --first-commit-add 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment