Some really quick git helpers
June 15, 2011 Leave a Comment
Here I’ve added a couple of useful tips for working with git. I’ll keep adding to it as I think of more but for now it’s a start.
So we all know it can be dangerous to remove remote branches and tags but once we know we need to do it what can we do?
Delete a Branch Locally:
$ git branch -d branch_name
Delete a remote branch:
$ git push origin :branch_name
This basically pushes nothing to the branch resulting in it being deleted.
Change the path (url) of a remote branch:
git remote set-url remote_name new_path
Delete a Tag Locally:
$ git tag -d tag_name
Delete a remote tag:
$ git push origin :refs/tags/tag_name
git ls-files
This one can be especially useful if you accidentally reset head –soft and want to delete your untracked files. In order to list all untracked files use $ git-ls -o. You could then for example run $ git ls-files -o | xargs rm to delete all of these files. Be aware that this command will list all files though. Including those you chose to ignore.
