0

So I work on a site with which I update via git push from my local to the server. (git push dev/live).

My problem is that currently I have been working on a big change to the site, but there has also arisen some bugs that need fixing on the live site.

How do I go about making small fixes to the live site without pushing the entire local repo to live?

Sneaksta
  • 1,041
  • 4
  • 24
  • 46

1 Answers1

1

You could use branches to fix your bugs and then merge to the master branch and push to the live website whenever you need.

To create a new branch and immediately switch on it: git checkout -b branchname (of course you can type any name instead of "branchname").

If you want to change branch just type git checkout followed by the name of the branch you want to work on (the main branch is called "master").

To merge the new branch into the main one, first switch to the master branch, as explained above (git checkout master) and then type git merge branchname. Of course "branchname" will be replaced by the actual name of the branch you want to merge.

For more information you can refer to this article: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging

MGA
  • 7,575
  • 1
  • 14
  • 10
  • What if I've already committed a whole bunch of changes on the master that I don't actually want to push just yet? – Sneaksta Apr 17 '13 at 14:42
  • Create a new branch like I explained above to save your work and then go back to the master branch and type **git reset --hard** to roll back the previous commit and the previous changes. – MGA Apr 17 '13 at 17:59
  • thanks for your reply, but what if I've done a lot of commits? Is there a way to go further back from there? – Sneaksta Apr 17 '13 at 23:23
  • **git reset --hard ** there are many questions about it on stackoverflow, for example look [here](http://stackoverflow.com/questions/1616957/how-do-you-roll-back-reset-a-git-repository-to-a-particular-commit) (I got the command line above from the accepted answer) or [here](http://stackoverflow.com/questions/2007662/rollback-to-an-old-commit-using-git), hope it helps! – MGA Apr 18 '13 at 08:52