I am using openshift server to host my php application. I have added files to my server using sftp to ~/app-root/runtime/repo directory. The same files are accesible over the web. But when I git clone my repository to my local machine I don't see my uploaded files in it. Neither when I add and push files using git are seen in my app-root folder. Any help is kindly appreciated
Changes made directly on the gear's repo/ dir are not tracked by git, and will be overwritten when you push your local git repo to the gear. To track them, scp/sftp them back to your local git repo and add/commit/push them across.
The alternative to scp/sftp is to run "rhc snapshot {appName}" which will take a backup of all your files (code and data in case of snapshot), then you can extract the files under the repo/ dir back to your local git repo, and add/commit/push them across.
Feel free to post to our forums: https://openshift.redhat.com/community/forums/openshift
Related
I created a folder on OneDrive called My files>GitHub>MedAverter. I note it's url:
https://onedrive.live.com/?id=CC97284F14BADC27%211034825&cid=CC97284F14BADC27
I downloaded GitHub Desktop and set the Current repository to the newly created MedAverter folder.
I navigate to my local code folder in git bash:
/c/users/greg/LaravelProjects/MedAverter
I enter the following command:
git remote set-url origin https://onedrive.live.com/?id=CC97284F14BADC27%211034824&cid=CC97284F14BADC27
To check it is correct, I do:
git remote -v
here is the output:
origin https://onedrive.live.com/?id=CC97284F14BADC27%211034824 (fetch)
origin https://onedrive.live.com/?id=CC97284F14BADC27%211034824 (push)
Note that it is shorter than the original?
I do a git status and see a bunch of unstaged files, as expected. I stage them with
git add .
Then I commit the files with:
git commit -m "first commit"
Then push the files with:
git push -u origin master
But get error:
fatal:
https://onedrive.live.com/?id=CC97284F14BADC27%211034824/info/refs not
valid: is this a git repository?
What am I missing?
In order to use an HTTP remote for Git, it either has to support the smart protocol, which requires a special server endpoint, or it has to support WebDAV, which is commonly referred to as the dumb protocol. In addition, the remote cannot use query parameters, since Git will not handle them.
If you want to use OneDrive with WebDAV, you'll need some way to get the initial repository structure up to the server, which will likely involve using a standard WebDAV client to upload a directory created with git init --bare.
As mentioned, you'll also need a WebDAV URL that doesn't include any query parameters; if OneDrive can't provide that, then you'd need to use a different provider.
Do note that you should not use OneDrive as a syncing tool for your Git repository across machines because doing so can cause corruption.
I strongly suggest that you do not use OneDrive shared folders to host a git repository you are working on locally whether you are syncing across machines or not.
One Drive has some challenges keeping a proper sync when files are deleted, and this can cause havoc on your working directory.
As of October 2022, this issue has not been resolved and I've been burned by it in the past.
Example:
Refactoring your code (or changing branches/commits) can result in files that need to be removed from your project. OneDrive doesn't always recognize the local file deletions and so it will synchronize the files back and whole folders/files can re-appear whenever this happens.
The working directly may then be polluted with folder/file additions that you did not intend and can cause havoc.
Bottom Line: Git is the tool to manage your working directory related to repo and collaboration. Backups need to be managed with the git repository stores itself, and do yourself a favour and don't mix OneDrive and Local repos or working directories
Here is a link with a "fix" that isn't a fix for this use case but explains the issue in better detail for reference:
https://www.urtech.ca/2021/01/solved-files-synced-to-onedrive-keep-reappearing-after-deletion/
I'm new with git and still a bit confused how to best manage a local repository with a webserver. Until now, I've just used a plain text editor and FileZilla to upload HTML and PHP code to webserver.
Now I would like to use git for versioning and I've created a local repository on my Ubuntu desktop and made some changes to my code. Do I still have to use FileZilla to upload code to webserver or is there a more comfortable way with a git command? - All I found on the web was to use push and pull, but only in conjunction with GitHub - since I don't need to share my code it with others, I don't want to make my code public on GitHub.
Is there a git command to upload commited HTML and PHP files to webserver? Or have I misunderstood something? - Or shall I think about it that my repository is the code on the webserver?
Any help welcome.
Have you git installed on your server?
Push your code to your account repository on GitHub / Gitlab or Bitbucket
2.In your html_public directory, run these commands
To initialize git in the folder
git init
To add your main remote where you will pull / push etc your code
git remote add origin https://your_remote_url.git
Recover the remote code
git pull origin the_branch_you_want_to_recover
or
git clone https://your_remote_url.git
or
git clone -u https://your_remote_url.git the_branch_you_want_to_recover
After intensive research today, I found git-ftp and I think that this add-on is exactly what I was looking for.
I have a number of currently live Magento websites which I'm looking to take copies of and integrate Git with Bitbucket into. I want to do this to make future changes traceable with the ability to be able to roll back should anything go wrong!
Here's how I understand it should work:
Create bitbucket repository
Install .git on both local machines and live server
Download copies of live site files and database
Clone repo to local machine
Import all files into cloned repo
Push back up to repo
Setup php file on live site to git pull from repo
Link php file as a Service Hook in bitbucket
What I need to know is if I'm missing anything from the above steps and how you would migrate a currently live Magento site to your local machine and get it all working again.
First of all here is my suggestion for your Git architecture:
Create two branch in your local and two branch in Bitbucket (Let's name them Dev and Master). It is very important to have a dedicated branch (Master) in Bitbucket that your server securely pulls from it; in this way you try to prevent messing things up.
In your local always push from your Dev branch and merge your Master branch after it. And in your server pull only from Master branch in Bitbucket.
For making a copy of your Magento:
First dump your DB and import it in your local DB. Then copy all the files from public_html folder in your server to your local. You might need to change a few things in your DB (in core_config_data table) and your .htaccess file (Here).
Take the DB user credentials from: app/etc/local.xml file and create this user in your local DB. If you are lucky enough it should do the job if not search for it, you'll find hundreds of dedicated questions/answers all over the Internet.
Apart from these, for automatic updates you should look for CI (continuous integration) tools like Jenkins. Have a look at these links (1, 2).
I am new to GitHub. I managed to install GitHub for Windows and created a github repository. I'm a PHP developer and this is my current situation before GitHub.
Currently, all of my work go to C:\xampp\Dropbox\* ("htdocs"). Everything I code is in there with each application under its own subdirectory. Whenever I need to update the production server, I FTP our production server and upload the necessary files. This is good when I am working alone but working with other developers would be hard because we need to know who edited which, when what was edited, etc.
Could you help explain how I can maintain my codes using GitHub? I suppose that I shouldn't make the entire htdocs as a local repository. I access my codes via http://localhost/ when testing it locally. Since I develop web applications using PHP, code changes regularly. We don't compile codes and I was used to simply saving all the files and letting Dropbox save all the versions I made.
It's a bit confusing what to do next since the GitHub for Windows application created local repositories in C:\Users\Admin\Documents\GitHub\test-app folder. Should I edit the code in htdocs and ALSO edit the code in My Documents\GitHub? Then also "push" the update to GitHub AND also update our production server via FTP?
So, to summarize, from the primitive perspective of web development, what steps must be changed so that I can enjoy the benefits of using version control systems such as GitHub?
Thank you!
The global idea is to use a versioning server to push code directly into your production server, bypassing FTP boring method.
You can tell GitHub application to clone your code at Xampp htdocs root, instead cloning it into your documents, if you have already initialized your repositories.
Every project must be a GitHub (or Git, more generally) repository.
So, you have to :
git init all your projects into your local server, at root of your project (so, not htdocs, but htdocs\<YOURPROJECT>
create repositories on GitHub for each of your projects
Follow GitHub instructions to initialize projects, git push on GitHub to finish.
You can do all that with a command line. In my opinion, it's easier.
Your code is on GitHub now. You won't have to edit your code into your documents AND htdocs if you initialize your repos in htdocs.
Next, it could be "fun" to install Git on your production server to grab most recent code from GitHub repository. Without Git, it's a pain in the a** to push code on a production server.
Now, when your local dev server and your production server are in sync, every time you will commit and push on GitHub, you can grab latest copy with a simple git pull on your production server.
I am very new to github. I was trying to pull a branch from a repository which contains some php code.
I used git clone <url>
then I used git checkout <branchname> to switch to a specific branch.
Since I am using Github for Windows, the files are stored in Github folder of My Documents. Now I want to test the code and make some changes to it in my localserver. So should I copy paste the project folder in the www directory of my wamp folder? Or should I do something else? And if after copying the folder, if I want to commit any changes, what command should I use to push?
Github for Windows does mention in the help page that:
GitHub for Windows is optimized to work with GitHub remotes — but if you wish to use a non-GitHub remote, it will work just fine. Set the remote manually in the settings tab and everything else should work as expected. You can also drag in repositories from the file system and GitHub for Windows will respect the configuration of the origin remote.
So you can pull from a non-GitHub repo, like I did in this answer or as illustrated in this blog post.
But from your local clone, you cannot easily push to another repo (like one in your wamp folder for instance)
it does not support multiple Git remotes and it will only work with the origin remote.
If you wish to push & pull to other remotes, we suggest you use the command line client that is included with the application.
An alternative to command-line would be to use a GUI which does support multiple remote, like SourceTree.
Or you can clone the GitHub repo from the command-line directly in the right folder, and then declare that local repo in your GitHub for Windows app.
Or you could create a virtual host that has a DocumentRoot of the Github folder of My Documents (meaning you don't have to move anything, and can keep using GitHub for Windows as you were).