While switching the branch , facing an error #21382
-
I’m remotely connected to the git project from the GIT Bash, while switching between the branches I’m facing the error error: The following untracked working tree files would be overwritten by checkout: .gitconfig Please move or remove them before you can switch branches. Aborting And when I’m doing the “git status”, it shows the local desktop changes not the project changes …/.eclipse/ …/.gitconfig …/.jenkins/ …/.m2/ …/.node_repl_history …/.npmrc …/.oracle_jre_usage/ …/.sonar/ …/.ssh/ …/.tooling/ …/.viminfo …/.vscode/ …/AppData/ …/Citrix/ …/Contacts/ …/Desktop/ …/Documents/ …/Downloads/ …/Favorites/ …/Links/ …/Music/ …/Pictures/ …/Saved Games/ …/Searches/ …/Videos/ …/node_modules/
nothing added to commit but untracked files present (use “git add” to track) What should be the approach to to resolve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @shweta13agg, Welcome to the Github Community Forum! The error shows you the file that prevent you from checkout, that file is in the dirty form in that branch so you need to change his form by move it to staged area or delete the changes made to that file. To move to staged area you need to add that file and commit:
To delete changes made to that file you need checkout that file:
The untracked files are the files that are not in the history yet. If you don’t want this files in the history you can add them to the .gitignore file, for example you don’t want the eclipse metadata you need to add the .eclipse directory into gitignore file:
And this resolve all your problem. Suggestion: you’re trying to add your entire home to a git repository, be carefull with the dimension of what you push. -Gabriele- Mark helpfull posts with Accept as Solution to help other users locate important info. Don’t forget to give Kudos for great contents! |
Beta Was this translation helpful? Give feedback.
-
Thanks @wabri it solve my issue. |
Beta Was this translation helpful? Give feedback.
Hi @shweta13agg,
Welcome to the Github Community Forum!
The error shows you the file that prevent you from checkout, that file is in the dirty form in that branch so you need to change his form by move it to staged area or delete the changes made to that file.
To move to staged area you need to add that file and commit:
To delete changes made to that file you need checkout that file:
The untracked files are the files that are not in the history yet. If you don’t want this files in the history you can add them to the .gitignore file, for example you don’t want the eclipse metadata you need to add the .eclipse…