this post was submitted on 25 Nov 2023
48 points (91.4% liked)
Git
2911 readers
1 users here now
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Resources
Rules
- Follow programming.dev rules
- Be excellent to each other, no hostility towards users for any reason
- No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.
Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Thanks. I somehow straight-up ignored gitattributes and can't recall to have seen them in projects. Glad that's past tense now and I will add presets from your link where appropriate (If I remember it). Never had conflicts with windows users on linux based repos but I suspect thats VSCodes merit in keeping the files as-is.
The two commands in your post are not mentioned in the linked repo-readme but instead in the github docs (see [1]).
I know
git reset
only from dealing with a detached HEAD. I did not understand the situation as well as thegit reset
command. Both is explained very good in [2].So here's the gist of my research (possibly wrong).
Before you even add the .gitattributes file you should add all unstaged changes, commit & push them. To quickly revert back when things go wrong: zip the whole project.
git rm --cached -r
: Normallygit rm
would remove a file from the filesystem in addition to the repo but the --cached says to only remove/untrack the file from the repo (what's inside the .git dir). Recursively removes every file. Cleans the current staging area too. So at this point you'd have to dogit add
again for every file but you wouldn't have lost any uncommitted changes in the working dir.Now for the dangerous part:
git reset --hard
This resets the HEAD to the most recent commit (and cleans the staging-area/index which was already done in the in git rm) and in addition possibly overwrites many unstaged/uncommitted changes with the files contents from the last commit.So to end this novel. If you havent commited everything before executing the commands your in for a bad time. As far as I see it.
[1].
[2]