An admin panel backend project in nest.js!
First, install TypeScript in your local project folder:
$ npm install typescript@5.4.5
Next, install all project dependencies:
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# unit tests
$ npm run test
When working across different operating systems (e.g., Windows and Linux), line-ending differences can cause unintended changes in your Git repository. This guide explains how to resolve these issues and prevent them in the future.
First, identify which files Git detects as modified:
git status
If files you didn’t intentionally modify are listed (typically due to line-ending changes), proceed to the next steps.
Add all modified files to the staging area:
git add .
This prepares the files for the next step.
Discard any unintended changes, including line-ending differences, by resetting the staged files:
git reset --hard
- All uncommitted changes (including line-ending changes) are removed.
- Files are reverted to their exact state from the latest commit.
To prevent line-ending issues in the future, normalize the line endings in your repository:
-
Add a
.gitattributes
File Create or update a.gitattributes
file in the root of your repository with the following content:* text=auto
This configuration ensures:
- Git converts all line endings to
LF
when committing. - During checkout, line endings are converted to the appropriate format (
CRLF
orLF
) based on the OS.
- Git converts all line endings to
-
Renormalize the Repository After adding the
.gitattributes
file, normalize the line endings across all files:git add --renormalize . git commit -m "Normalize line endings"
This updates the repository to ensure all files comply with the specified line-ending format.
After completing the above steps, check that no unintended changes remain:
git status
If the working directory is clean, the issue is resolved.
Here’s a consolidated list of commands to resolve line-ending issues:
git add .
git reset --hard
git add --renormalize .
git commit -m "Normalize line endings"
To avoid recurring line-ending problems, ensure consistent Git configurations across all environments:
git config --global core.autocrlf input
This converts CRLF
to LF
on commit but does not modify LF
on checkout.
git config --global core.autocrlf true
This converts LF
to CRLF
on checkout and back to LF
on commit.
By following these steps, you can resolve existing line-ending issues and maintain consistent behavior across different operating systems.