https://github.com/tomashubelbauer/git
Tips and tricks for using Git
https://github.com/tomashubelbauer/git
git kb knowledge-base tips-and-tricks
Last synced: 2 months ago
JSON representation
Tips and tricks for using Git
- Host: GitHub
- URL: https://github.com/tomashubelbauer/git
- Owner: TomasHubelbauer
- Created: 2019-12-23T17:54:17.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-04-14T20:19:41.000Z (about 4 years ago)
- Last Synced: 2025-06-01T16:42:17.081Z (about 1 year ago)
- Topics: git, kb, knowledge-base, tips-and-tricks
- Language: Markdown
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git
## Set up
https://github.com/tomasHubelbauer/git-config
## Pull With Submodules
`git config --global submodule.recurse true`
[Stack Overflow answer](https://stackoverflow.com/a/49427199/2715716)
## Delete file with its history
https://stackoverflow.com/a/872700/2715716
Implemented in https://github.com/TomasHubelbauer/git-erase
## Delete file's history keeping its current version
```sh
# Remove file with its history from the local repository
git filter-branch --force --index-filter "git rm --ignore-unmatch name.ext" --prune-empty HEAD
# Restore file's latest version from the remote repository
git checkout origin/main -- name.ext
```
`git checkout` can't work from the local repository, because in it, after the
history was rewritten, the file never existed, so it has nowhere it could be
recovered from. For that reason, it needs to be recovered from the remote copy
where the new history has not been forced-pushed into yet, so the file still
exists there.
Example: https://github.com/TomasHubelbauer/tomashubelbauer