Posts tagged Git


Git – Remove all untracked files


Sometimes you start down a path, and realize that there is a better approach or you just don’t have the time to continue. In git it’s easy to do a

git checkout -- .

for all existing files, but more difficult for untracked files. To remove all untracked files try this:

rm -rf $(git ls-files --others --exclude-standard)
General Category

Git – Revert Multiple Locally Changed Files


I use a windoze box at home and by default it uses the lame microsoft line endings vs linux line endings, which can wreck havoc on bash scripts. So I recently ran a command similar to the following:

find /path/to/files -type f -exec dos2unix {} \;

Much to my dismay, I found that it also converted binary files (.pngs, .gifs, etc), even though, according to the docs, it’s supposed to skip binary files by default. So I had to revert back all the binary files which were converted. Rather than do them one by one I tested and issued the following command (your mileage may vary):

gstatus | fgrep -is png | git checkout -- $(awk '{ print $3 }')
Linux Logo

Linux – CentOS6 – Git – fatal – Where do you want to fetch from today?


If you are using GIT as your version control and you attempt to do a `git pull` and get a “fatal: Where do you want to fetch from today?” message, you need to do either of the following:

# Specify the remote repo
mkdir repo
cd repo && git init
git pull

# Or
# Clone the repo
mkdir repo
cd repo && git clone git pull .
git pull

Linux – Ruby – Capistrano – GIT – No Such File or Directory – Errno::ENOENT


If you are running capistrano to execute commands on another server and get a message that looks like:

No such file or directory - /usr/local/git/bin/git ls-remote master (Errno::ENOENT)

Be sure the user whom you are logging in as through capistrano has access to `git`. To test whether the user has access, ssh as the user and type `git`, if you get a bash error, then set the path in the user’s ~/.bash_profile. Otherwise you should see a list of git options.

GIT – Basic Usage Guide


Living doc storing commonly used git commands.

Revert unstaged changes

git checkout -- .

Rename repo

 vi .git/config #change url in remote origin section to new name

Now change the name of the remote repo.

git push #test to make sure things weren't broken

Remove all untracked files

git clean -f -d #will also remove untracked dirs

Reset local repo

git reset --hard HEAD #useful for recovering after a git rm -r .

Automatically Stage Tracked Files (and Mass Remove Deleted Files)

git add -u
Go to Top