commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
from http://git-scm.com/book/en/Git-Tools-Stashing
Useful for when stash cannot be applied to current branch
Full output in one single git command, no pipes nor other process invocations.
Will also work under cmd on Windows, with MSysGit, and can be aliased, simply add
[alias]
branch-rel = "for-each-ref --sort=-committerdate --format='%1B[32m%(committerdate:iso8601) %1B[34m%(committerdate:relative) %1B[0;m%(refname:short)' refs/heads/"
to your .gitconfig file.
Find all the occurrences in the git repo of 'foo' and replace with 'bar'
The option --porcelain makes the output of git easier to parse.
This one-liner may not work if there is a space in the modified file name.
A little used command, but one I find very useful when needed.
Note: It only works on gitignores in the top level directory.
This oneliner gets all the 'modified' files in your git repository, and opens all of them in vim.
Very handy when you're starting to work in the morning and you simply want to review your modified files before committing them.
Maybe there are better ways to do that (and maybe integrated in vim and/or git, who knows), but I found quicker to do this oneliner.
This command should be copy-pasted in Windows, but very similar one will work on Linux.
It uses wget and sed.
Assumes you've cd'd to the folder in which all your git repos reside; you could run it from ~ without -maxdepth, although that might make find take quite a while longer.
If you have several processor cores, but not that much ram, you might want to run
git config --global pack.threads 1
first, since gc-ing can eat lots of ram.
It's useful to run run git st before you commit changes. To see an individual commit it's good practice to type git diff . If you are happy with what you see, to add the file, just type ^diff^add
Add this line to your ~/.gitconfig for a git alias "git brd" (i.e., brd = (br)anch+(d)ate) which sorts branches by date. Allows you to pass in limited "git branch" options such as "-r" (remote) or "-a" (all). (Note: forum added "$" prefix to command; obviously in gitconfig there is no "$" prefix.)
g clone --local --bare . /repo.git
g remote add alias /repo.git
g push alias branch
g log -p filename
g checkout SHA1_rev
g reset --hard
g checkout -b new_branch
g ls-files --deleted
This command will automatically find the latest version of the file that was deleted and restore it to it's previous location. If, of course, your file was kept in a git repository...
I found this command on http://stackoverflow.com/a/1113140
Uses line-porcelain in git blame, which makes it easier to parse the output.
Written for Mac OSX. When you are working in a project and want to open it on Github.com, just type "gh" and your default browser will open with the repo you are in. Works for submodules, and repo's that you don't own.
You'll need to copy / paste this command into a gh.sh file, then create an alias in your bash or zsh profile to the gh.sh script. Detailed instructions here if you still need help:
Simpler and without all of the coloring gimmicks. This just returns a list of branches with the most recent first. This should be useful for cleaning your remotes.