Reputation: 433
I have a site that need some tweaks. I'm the only developer. I do not know what files will be modified. I do not want to store untouched files in the repository. I want to store in repository (local and remote) only modified files.
Could you please describe or point to the optimal strategy to reach what I want?
Upvotes: 1
Views: 192
Reputation: 78843
Here's a variation of the method that I use for my dotfiles in my home directory; I want to keep my dotfiles version controlled, but I don't want to put my whole home directory in git, obviously.
First, create a git repository: git init .
in the directory that you want to manage.
Next, add a .gitignore
that contains everything. For example: echo '*' > .gitignore
. I recommend that you git add .gitignore && git commit -m"Adding .gitignore"
Now you can git add ...
and git commit
any files that you change. However, you must do this manually. git status
will not show you files that you've changed from their initial state (since they're ignored) and there is no mechanism to snapshot the directory at the point that we made a git repository and have git automatically notice that we made changes to the files. (To do this, you would need to create a git repository the proper way.)
However, once a file has been added to your git repository, it is no longer ignored (.gitignore
applies only to files that aren't yet in your repository), so once you've added a file, you will see when you continue to change it.
Upvotes: 2
Reputation: 26825
Initialise the repository with the entire site as is. Commit it.
Then you're free to make changes and commit those changes.
The way git stores changes it with changesets, it needs a base to work from in order to figure out what those changesets consist of.
You could potentially create patch files instead but you wouldn't need git for that.
Even though you're the only developer, in the long term for your own sanity and ability to maintain the project, you're better off with a full repository of the codebase. If you only have patches you have no context of what you were working on and will have a hard time in the future going back to work on it again.
Upvotes: 4