-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should yarn.lock be treated as a binary file in git? #1776
Comments
No it shouldn't. The file is plain text and there can be merge conflicts in the file that you may need to resolve. |
In the documentation is written that the yarn.lock file should not be touched to avoid problems and only yarn itself should deal with it. Then how I resolve a merge conflict? |
@kittens is the right thing to do when there are conflicts to blow away the lock file and re-run yarn? Seems to me that'd get what you need? |
@dbashford the problem with blowing it away and re-running yarn is that you'll get more changes than you wanted. For example, tilde versions will be upgraded, even though you didn't run |
@dbashford then it's easier to just put the yarn. lock file in the gitignore |
The approach that has worked for me so far is this:
When the first conflict arises, I checkout the
This generates a new
And I'm back in business. |
Note that even if you're not manually resolving the merge conflicts, having it be a non-binary file means you can see the merge conflicts, which is still valuable information. |
Related, even if there are no merge conflicts, can we always assume that git has merged two versions of a yarn.lock file in a way that results in a valid/correct file? It seems wrong to let git update the contents of the file at all if yarn is the only tool that is supposed to manage its content. |
I'm not sure that automerging YAML will always result in a valid file, especially given:
|
@danny-andrews can you explain how? |
When you wipe out |
That's why I suggested |
@IanVS yes, that is the correct way to do it. Though I'd recommend |
Good point, @idris. I typically rebase onto master, which is the example I used above, but that won't always be the case. |
@IanVS I didn't understand what that command did. That's much better than manually copying and pasting |
This is related: #3544 |
Isn't @IanVS's approach compatible with having the lockfile be a binary file? If I understand correctly the idea is to never merge, just throw away what you have and replay your |
here is my approach, to add a bash script
|
Peer Dependencies: - Previously `yarn install` would output warnings for missing deps eslint and jest. This resolves those warnings. Treat yarn.lock as a binary file: - So that git doesn't try to merge changes in the file. Yarn is the only thing that should make changes or updates to yarn.lock - This should make diff's on PRs more manageable and less awkward since the lockfile won't count in the diff. - See discussion here on how to handle merge conflicts with yarn.lock: yarnpkg/yarn#1776 (comment)
Peer Dependencies: - Previously `yarn install` would output warnings for missing deps eslint and jest. This resolves those warnings. Treat yarn.lock as a binary file: - So that git doesn't try to merge changes in the file. Yarn is the only thing that should make changes or updates to yarn.lock - This should make diff's on PRs more manageable and less awkward since the lockfile won't count in the diff. - See discussion here on how to handle merge conflicts with yarn.lock: yarnpkg/yarn#1776 (comment)
Peer Dependencies: - Previously `yarn install` would output warnings for missing deps eslint and jest. This resolves those warnings. Treat yarn.lock as a binary file: - So that git doesn't try to merge changes in the file. Yarn is the only thing that should make changes or updates to yarn.lock - This should make diff's on PRs more manageable and less awkward since the lockfile won't count in the diff. - See discussion here on how to handle merge conflicts with yarn.lock: yarnpkg/yarn#1776 (comment)
Peer Dependencies: - Previously `yarn install` would output warnings for missing deps eslint and jest. This resolves those warnings. Treat yarn.lock as a binary file: - So that git doesn't try to merge changes in the file. Yarn is the only thing that should make changes or updates to yarn.lock - This should make diff's on PRs more manageable and less awkward since the lockfile won't count in the diff. - See discussion here on how to handle merge conflicts with yarn.lock: yarnpkg/yarn#1776 (comment)
If you are merging the main branch. Then you can also use git checkout --theirs yarn.lock
git add yarn.lock
git commit |
@shiplu It's always good to run |
http://stackoverflow.com/questions/40532940/should-yarn-lock-be-treated-as-a-binary-file-in-git[CLOSED]The text was updated successfully, but these errors were encountered: