-1

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.