Im pretty new to git and i still couldn't figure out the best approach, when it comes to flow of git.
Im using this flow, but it seems to cause errors. Could you fix it for me?
->git clone [repo name]
->cd [repo name]
->git status
*On branch master nothing to commit
->git checkout -b "class-lib-move"
->start [project name].sln (openning code in visual studio)
Making some changes...
->git add .
->git commit -m "changes ..."
->git checkout master
->git merge class-lib-move
*error: Your local changes to the following files would be overwritten by merge:
.vs/VideoToText/v17/.suo
/obj/Debug/net6.0/VideoToText.GeneratedMSBuildEditorConfig.editorconfig
VideoToText/obj/Debug/net7.0/VideoToText.GeneratedMSBuildEditorConfig.editorconfig
VideoToText/obj/Debug/net7.0/VideoToText.assets.cache
VideoToText/obj/VideoToText.csproj.nuget.dgspec.json
VideoToText/obj/VideoToText.csproj.nuget.g.props
VideoToText/obj/project.assets.json
VideoToText/obj/project.nuget.cache
Please commit your changes or stash them before you merge.
->git add .
->git commit -m "useless commit"
->git merge class-lib-move
->git status
warning: Cannot merge binary files: .vs/VideoToText/v17/.suo (HEAD vs. class-lib-move)
Auto-merging .vs/VideoToText/v17/.suo
CONFLICT (content): Merge conflict in .vs/VideoToText/v17/.suo
Auto-merging VideoToText/obj/VideoToText.csproj.nuget.dgspec.json
CONFLICT (content): Merge conflict in VideoToText/obj/VideoToText.csproj.nuget.dgspec.json
Auto-merging VideoToText/obj/project.assets.json
Auto-merging VideoToText/obj/project.nuget.cache
CONFLICT (content): Merge conflict in VideoToText/obj/project.nuget.cache
Automatic merge failed; fix conflicts and then commit the result.
And there goes my flow. I only see an option to upload the feature branch to remote, completely delete the folder,git clone repo again and and finaly merging it. Am i missing something out?
Problem seems to be caused by visual studio. In the moment im switching branch to master, it overwriting some files by itself...
The problem is that your keep too much stuff in the repository. For example, the .vs
directory need not be under version control, nor should be the build artefacts and generated files such as obj/Debug/
, nor (most likely) stuff in any *.cache
file or directory.
When you set up the repository, you should have created a .gitignore
file that listed everything that is not source code, so that git add .
would not have added these files to the repository.
Fixing this after the fact is possible, but is going to cause a tremendous headache for anybody who has also cloned the repository (instructions are basically to git rm --cached the_unwanted_files
after you have added the_unwanted_files
to .gitignore
).
My alternative recommendation is: if you can, start with a new repository.