Domanda

Problem:

I have just one branch master i cloned the repository, i make changes, commit -a -m "msg" and push them back --> the site updates. This is OK

But i can upload new files to website through webforms and they get deleted every time i push!

I tried googleing and searching and reading but i clearly dont understand something, i've added the specific folders to git ignore and they are ignored when commiting but push clearly deletes those files...

What is the correct approach to this problem? (i know i could clone before each push but i guess there is a much easier way and more sensible way with some combination of rebase fetch or something...)

È stato utile?

Soluzione 2

After a lot of digging i managed to find the answer on OpenShift forums and stack...not sure how it didnt pop out sooner.

Runtime modifications will modify your code on the gear. Since those changes bypass git, they won't be version controlled. Your local repo will be out of synch after those runtime changes so it is recommended to check those changes into your repo and push them back to gear so as to track those changes.

Long story short: Files uploaded to server outside commits/push arent monitored by git and they get overridden by git afterwards.

Solution:

1) If you are uploading files to lets say uploads folder, ssh into your app, and do the following :

    ln -sf $OPENSHIFT_DATA_DIR/uploads $OPENSHIFT_REPO_DIR/php/uploads

also be sure to make uploads folder with mkdir before that.

This will make that directory publicly accessible, and since data directory isnt git controlled it makes the data safe from push.

2)

0) Ensure that all your local changes are in synch 1) Make changes to your app at runtime (like the install a theme) 2) take a snapshot of your app with "rhc app snapshot save -a {appName}" 3) Overwrite all your local repo files with the files in the snapshot.tar.gz (everything in app_root/repo/* 4) run "git add ." on your local repo 5) then run "git commit -a -m "upgrade to 3.4" and "git push"

More info:

https://www.openshift.com/forums/openshift/one-newbie-question

https://www.openshift.com/forums/openshift/php-uploads

https://www.openshift.com/page/openshift-environment-variables

Altri suggerimenti

Even though it is possible to work in master it really not feasible if there is more then 1 clients working on the repository. In this case your computer and the webform. Creating feature branches allow you to work more efficiently.

C1--->C2--->C3--->C4--->C5<--master
                        |
                        origin/master

Before working on some feature or a hotfix you can git checkout -b featurebranch to create a new branch and make your changes. After making the changes you can commit the changes with git commit -a -m "msg".

                          /--C7<--featurebranch
                         /
C1--->C2--->C3--->C4--->C5--->C6<--origin/master
                        |
                        master

So you commited your changes to your feature branch but now you want to merge the branch back in to master. However, you made some changes remotely and origin/master now points to a commit you don't have locally. On master branch you can git pull origin to fetch+merge all new changes from the remote essentially getting C6 and moving the master branch pointer to C6.

                         /--C7<--featurebranch
                        /
C1--->C2--->C3--->C4--->C5--->C6<--master
                              |
                              origin/master

After this you want to reapply your feature branch commit onto the new master. So you use git rebase master featurebranch.

                                /--C7<--featurebranch
                               /
C1--->C2--->C3--->C4--->C5--->C6<--master
                              |
                              origin/master

Now that C7 is based on C6 you can simply merge it using git merge featurebranch on master. As the repository was in sync before pushing no longer you will see files added from a webform deleted. Finally git push origin master.

C1--->C2--->C3--->C4---->C5--->C6--->C7<--master
                                     |
                                     origin/master
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top