Category Archives: Version Control
Remove Unwanted Files From Git History
Here’s an example of how to remove every *.pyc file from every commit in Git history. It is adapted from this Git help page.
Rewrite history
Run git filter-branch
, forcing (--force
) Git to process—but not check out (--index-filter
)—the entire history of every branch and tag (--tag-name-filter cat -- --all
), removing the specified files ('git rm --cached --ignore-unmatch *.pyc'
) and any empty commits generated as a result (--prune-empty
). Continue reading Remove Unwanted Files From Git History
How do you discard unstaged changes in git?
How do you discard unstaged changes in git?
git clean -df
git checkout — .
Adding Git version control to web sites
Here’s a little script I made to make it easy to put a number of existing web sites residing under /var/www under version control by Git. Regarding security, it is obviously not a good idea to initialize the Git repository directly under the site directory, since from there it might be served by the web server to the outside world. And that is not what I want. Instead what I want is to have the Git working directory directly in the site directory that is served, and the repository somewhere else. That is perfectly possible with Git, just by setting one or two environment variables. Continue reading Adding Git version control to web sites
Ignoring files · GitHub Help · Global .gitignore
Ignoring files · GitHub Help · Global .gitignore
How to import existing GIT repository into another?
Git undo, reset or revert?
Also useful:
1 |
git rm -r --cached * |
That will recursively remove every file from the index (files staged for commit).