1

I am developing a PHP project using github.

My editor of choice is Coda 2 which has a function of saving at the same time on local computer and on the FTP server.

Now, I also have the need to commit the changes to git, and therefore to github as well so, every time I am saving (both locally and remotely) I commit to github.

The problem arises now:

What if I need to revert changes? Those would be only affected on github and will probably lead to a mess. What I am doing currently to "revert" is just writing manually the pieces of code that need to be backed up.

hakre
  • 193,403
  • 52
  • 435
  • 836
john smith
  • 565
  • 1
  • 10
  • 20

3 Answers3

5

You are using Git wrong. There is no reason to commit when you save. Also it's okay if you keep your local git repo for developing and sync with github from time to time only.

So all you need to do is to change your workflow. Remove the commit on save.

hakre
  • 193,403
  • 52
  • 435
  • 836
2

Don't upload manually using ftp, instead clone the repository on the server and pull there.

Of course this is only possible if you have shell access to the server. If you want to do serious development you should have a server with shell access.

Niko Sams
  • 4,304
  • 3
  • 25
  • 44
0

You misunderstand the purpose of git. It is not a backup tool, but a collaboration tool along with version control system. It never meant to backup your code. It is of course possible, but git's and any other VCS' nature is to provide readable and trackable flow of the project's development phase.

You basically never commit code without explaining changes you've done to the file(s). VCSs encourage you to describe the commit and it's purpose so that the project's team could get into it and see why a certain change was made.

However, to adopt git's capabilities I would suggest making a backup branch and committing files there, so that you know that specific branch is nothing more than chaotic code flow. That at least will make things clear.

Then, when a certain feature is ready and tested, you can squash-merge backup branch into dev branch.

This way you will get organized structure of your repo and you'll be able to revert or pull from the dev branch the state of the code that you really need.

EDIT:

I also suggest having a look at successful git branching blogpost. In it's time it made me understand how git project evolves and develops.

Community
  • 1
  • 1
Aleksandr Makov
  • 2,820
  • 3
  • 37
  • 62