Branch x in my git repository contains the undesired build files. It happened because I do not separate build directory from the source code and I git add-ed the build files. The main branch is in a good shape and does not have the build files tracked. How do I create a new branch starting from x (so that it preserves its commit history) but with the build files removed from tracking? There are tons of build files in my project. Going forward, if I were to separate build files from the source code in its dedicated build directory, how do I go about developing the code? In particular, after making some changes in a folder, I would normally run make from inside the folder so that it compiles only the files in this folder. Can I run make from the build directory to compile only the files in the recently modified directory?
Add a comment
|
1 Answer
Switch to your new branch by using command :
git checkout x
and then command to add build file to .gitignore to untrack them from git which are currently tracked by it.
echo "build/" >> .gitignore
git rm -r --cached build/
but add actual file path at build/ which you want to untrack from git.
1 Comment
nougako
The problem is I don't keep track of the build files since I don't write the program. I don't exactly know where each of them is.