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. Show Sample Output
Revision: HEAD
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.) Show Sample Output
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
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.
A little used command, but one I find very useful when needed. Note: It only works on gitignores in the top level directory.
Place in .bash_profile Show Sample Output
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. Show Sample Output
Opens all files in the index (modified plus not added yet) in tabs in vim.
"git grep" automatically excludes untracked files (e.g. compiler output) and files under .git directory. If no directory or file is given, it will recursively search through the current directory.
While edtiing a project under git, it is sometimes nice to sync changes immediately to a test machine. This command will take care of this if you have inotifywait installed on the developement machine. Note the -R (relative) in rsync. with rsync foo/bar/baz user@host:dest/dir/ it will put 'baz' in dest/dir/foo/bar/ which is what we want. this can be turned into a function for additionnal flexibility : function gitwatch() { if [ -z $1 ]; then echo "You must provide a rsync destination" return fi while true; do rsync -vR $(git ls-files | inotifywait -q -e modify -e attrib -e close_write --fromfile - --format '%w') $1 done }
Works even with spaces in filenames. As an alias in .gitconfig: [alias] editchanged = "!git status --porcelain | sed -ne 's/^ M //p' | tr '\\n' '\\0' | tr -d '\"' | xargs -0 vim"
Downloads this raw script https://github.com/git/git/blob/master/contrib/completion/git-completion.bash from Github, copies it to your home directory, autoloads it in ~/.bashrc and sources it.
Replace "Oct 2" in the first grep pattern to be the date to view branch work from Show Sample Output
git fetch --all git reset --hard origin/staging
This creates an alias that will do a 'git archive' command to package up the current repo into reponame-shorthash.tar.gz, in the current directory.
List all dependencies manifests so you can install them. In a scenario where you want to deploy a number of web applications and run their dependency managers, how could you run all of them in a systematic order. One of the complexity is to ensure you get only your own top level dependencies. That way, you don recursively call development dependencies of your own dependencies. Otherwise you might end up discovering dependency management manifests that are already been pulled by your own projects. # Using this command This command helps me find them and I can then run what?s required to pull them from their respective sources. This command assumes the following: 1. Your code checkouts are in a flat repository layout (i.e. not nested). 2. Finds manifests for: - NPM (nodejs), - Composer (php), - bower, - requirements.txt (Python), and - git submodules Show Sample Output
This is useful as a git hook to print out the directories that had files changed on a commit. Each directory is its own package. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: