I just got a new job and one of my reponsibilities is to manage a couple of FreeBSD boxes running PF as a packet filtering solution. The firewalls used to be managed by a single person, but now we are 3 guys fixing the same configuration files possibily at the same time. I want to use git to be able to work on change requests in a local copy and push the changes to the server when I am done. This would give me: version control, fast rollbacks and conflict management. I fired up a virtual machine for tests and here is what I did until now.
run git init
inside /etc
and /usr/local/etc
did a git clone
inside /usr/home/myusername/config_sync/
for both local repos:
git clone -l /etc etc@localhost<br>
git clone -l /usr/local/etc usr_local_etc@localhost<br>
Thats what I thought I could do:
Change pf.conf;
run git add pf.conf;
run git commit -m 'comment'
run sudo git push
But this is what is happening. Although I have not changed anything in the pf.conf file in /etc, git acknowledges the remote commit but considers that the local copy is a newer version that undo everything I did.
For example, if I add the '#test' line inside my working copy and push it to /etc, here is what a sudo git diff master would show me at /etc.
diff --git a/pf.conf b/pf.conf<br>
index 31c4c68..76d693b 100644<br>
--- a/pf.conf<br>
+++ b/pf.conf<br>
@@ -1,5 +1,5 @@<br>
#MACROS<br>
-#test<br>
#Hello from origin#<br>
##Firewall Interfaces<br>
This is because when you push up to your repo in /etc your changes go into the repository not into the working copy. You have to check out the latest files from the repository branch after you push your changes up, otherwise the working copy in your upstream repo won't be updated.
Given a master repo in /etc, and a clone in /home/me/etc_clone, your workflow could be something like:
$ cd /home/me/etc_clone
$ vim pf.conf #make changes
$ git add pf.conf
$ git commit -m "updates"
$ sudo git push
$ cd /etc
$ sudo git checkout -- . #sync working copy with index