Run the above command for any other untracked files you do not want or move them out and switch branches. If you do not care for these files, switch back to the branch where the persistent directory does belong and run something like, find repo_root -name ".DS_Store" -type f -print -delete This will show the untracked files causing the directory to persist the branch change. Switch to the branch where the persistent directory does not belong and issue tree -a repo_root (make sure you have tree installed). When you switch branches, since Git does not track directories and only files, the directory with the ignored auxiliary files stays since it does not become empty. e., your working tree ( git status) is clean.Ĭhances are that you are on a Mac and are ignoring the auxiliary files it creates, e. Efficient branch switching is important to safely switch from one branch and commit your changes to the desired branch. You also switch branches frequently based on priorities. If anyone arrives here with the same situation as I was in, you are wondering why are you carrying over directories from the branch you switched from even though you had no uncommitted changes, i. Introduction When working on a project, you usually work on more than one branch at a time. I recommend you to not play with git history as a beginner. a) Switching branches without committing local changes apply the stash when you are ready to go back to the branch. 2) It seems like you want to revert back the changes. You can view your stash list using the command git stash list. Updating the files in the working directory. I tried using "git add" but the changes are visible in both branches.ĭo I need to run "git commit" before switching between branches to avoid this? 1) Stash your changes, checkout to another branch, make some changes there and come back to your original branch and apply/pop your stash. The git checkout command switches branches or restores working tree files operating on files, commits, and branches. Is not that the reason of creating branches? I thought that, while using branches, whatever you do in one branch, it's invisible to all the other branches. I am working on a feature branch and have not finished the work there - Now I need to change to a different branch to fix something. No changes added to commit (use "git add" and/or "git commit -a") " to discard changes in working directory) This is basically what I'm doing: $ git clone However, I tried then using git add, but didn't fix the problem. I'm really new to git and I've been trying to understand why git keeps showing whatever I changed in one branch in another branch when I run git checkout to switch between branches First I tried not using git add and didn't work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |