commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
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 is useful when you are uploading svn project files to a new git repo.
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.
Git uses secure hash sums for its revision numbers. I'm sure this is fine and dandy for ultra-secure computing, but it's less than optimal for humans. Thus, this will give you sequential revision numbers in Git all the way from the first commit.
If you don't have html2text
This fixes a bug found in the other scripts which fail when a branch has the same name as a file or directory in the current directory.
Great way to quickly grasp if a locally cloned repository originates from e.g. github or elsewhere.
attempts to delete all local branches. git will fail on any branches not fully merged into local master, so don't worry about losing work. git will return the names of any successfully deleted branches. Find those in the output with grep, then push null repositories to the corresponding names to your target remote.
- your local and remote branches are identically named, and there's nothing extra in the remote branch that you still want
- EDIT: you want to keep your local master branch