Git: Discard All Local Changes and Get a Fresh Copy from GitHub
· 5 min read
A common and reliable way to get a fresh copy from a GitHub repository, while preserving specific local files like .gitignore
, is to use a combination of git reset
and git clean
. This approach ensures your local branch exactly mirrors the remote branch, without leaving behind any untracked or unwanted files.