Search code examples
gitgithubversion-control

Github (or other SCM) Tracking only specific files


I am working on the game mod and want to manage the work I am doing on some VCS, i.e. github. The work is done on several files accross several subfolders. Thus it would be logical to have an entire game as a project. But I don't want to upload the entire game to github. It would be ideal if it was possible to manage just the files which were changed. That way it would be also eas(ier) to share this project with anyone who is insterested.

So, basically what I want is:

  1. the entire project on git locally
  2. only upload to git hub the files that have changed or/and the specific files (as per TTT comments below) I want to push to remote repo.

I saw similar question here: What is the best strategy to store in repository only changed files?

.gitignore is an option, but feels quite cumbersome. And managing this manually kind of defeats the point of having it on github to start with.

Also, the above link was for the question asked 6 years ago.

Any new ideas for this solution?


Solution

  • Obviously the easiest way is to simply .gitignore everything except the files you would want to push, but you lose all the benefits of source control for everything else...

    Although a little cumbersome, if you're willing to maintain two branches, this workflow would be pretty straight forward:

    • A branch branch-to-push would contain commits that modify only the files you wish to push.
    • A branch do-not-push would contain everything you wish to track locally.

    You would work out of do-not-push, and anytime you wish to modify file(s) that you would want to push, switch to branch-to-push, commit the change, then switch back to do-not-push and merge in (or rebase onto) branch-to-push.