Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 3

While switching the branch , facing an error

Solved! Go to Solution.

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?

2 Replies
Solution
Commander Lvl 2
Message 2 of 3

Re: While switching the branch , facing an error

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:

git add .gitconfig
git commit -m 'Update (.gitconfig)"

To delete changes made to that file you need checkout that file:

git checkout -- .gitconfig

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:

.eclipse/

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!

Copilot Lvl 3
Message 3 of 3

Re: While switching the branch , facing an error

Thanks @Wabri it solve my issue.