[Git] Your local changes to the following files would be overwritten by checkout
[Git Error] Your local changes to the following files would be overwritten by checkout
Git separates all branches with separate files (basically keeps track and indexes the changes made to the repository), if you change the dependencies of one branch and expect the dependencies to propagate to other branches when you change the branch, things might not happen that way. This most likely to happen when gitignore is not updated and is tracking dependency changes, for example, files in a vendor folder. Good Rule of Thumb, keep a small number of files that are tracked by git, this way when you Push to the remote repository the binary files are not pushed.
If Git is tracking or shows, you have 5K ( It can be any large number of files/changes ) files that have been changed, then chances are that it is tracking dependency files, which is not good. It is overwhelming to deal with all the color coding and you might get carried away with not knowing what to do. But this is the time when you want to take to teach yourself about Git and remember always ask, there is no stupid question, every question is valid, JUST ASK someone.
Working on the team of Developers, and other developers are using a different version of Ruby. You end up with a different version of Ruby when you do: bundle install, bundler installs dependencies that are compatible with the version of Ruby that you defined in your Computer/OS Environment Variables or have installed on your computer.
This is common to many git problems when you find yourself in this scenario, make sure to consult with your team what version of Ruby or .Net framework they are using or else, someday, this would bring a lot of conflicts when Pulling and Pushing to the remote repository.
Make sure you consult with your team on what version of platforms they are using. This will save you a lot of headaches of troubleshooting. When installing dependencies, remember to stop and think whether you are doing the right thing, or else you will find yourself troubleshooting the wrong installation and end up breaking the application.
Check in the Environment Variables and see what kind of applications are in the PATH, make sure they are the right version.
Make sure you have a gitignore file present in your Project root directory and double check to see if it ignores unnecessary files and folders.
Remember, Git can bring a lot of trouble if you don't understand it. Make sure you educate yourself on how it works: Start with reading the git documentationmoreover, it is just another application made to help you manage the Working Repository.
Try to avoid using different Git clients on one project, this might bring problems in terms of detecting what changed. For Example, using Source Control built in Visual Studio Code as well as utilizing the inbuilt GitFlow mechanism in GitKraken. Problems might arise when one Git client modifies a file and the other fails to detect the changes.
Pay attention to what OS other developers use to develop the application, sometimes, files modified on Mac would have a different encoding that those on Windows (this statement is not proven, just saying)