Git Trying to commit a file restructure, no files have been edited - php

I have just begun learning the basics of Git.
I have installed Git locally and successfully integrated it to clone repos into my xampps/htdocs.
Now locally, in this repo I have moved all the files into the php_Basics folder. But when I try and commit to sync up with my GitHub repo it says no changes added to commit.
How do I commit the file restructure, and sync it to the GitHub repo?

Source:Reference
Details about github
Checklist------------------------------------
Move files to git cloned repository if not use git init then move files
configure git username
check status --- git status you will see changed files
git add file to staging for commit
git commit
git push

Note: if the editor for the commit message is finicky, you can start with a shorter commit message in command line:
cd /path/to/local/repo
git add .
git commit -m "my message"
git push -u origin master

Related

Git: how to unignore all Symfony vendor files?

unfortunately I can't use composer, due to low memory on the webspace. That's why I'm trying to push vendor/* to the git repository, to be able to pull the full project, including the dependencies.
In my .gitignore I'm forcing git to unignore the vendor files by !/vendor/*.
It works for most files, but not for /vendor/friendsofsymfony/jsrouting-bundle.
Content of /vendor/friendsofsymfony/jsrouting-bundle/.gitignore:
/phpunit.xml
/composer.lock
/composer.phar
/vendor/
/node_modules/
My repository is hosted at BitBucket. I don't know yet the meaning of the different folder-icon and the hashs next to it. If anyone knows, please comment.
Does anyone know how to force git to handle all the vendor files?
Thanks in advance!
Solutions
As the jsrouting-bundle is a git submodule, I chose this solution:
git submodule add git://github.com/FriendsOfSymfony/FOSJsRoutingBundle.git vendor/friendsofsymfony/jsrouting-bundle
Another way would be to use the deps file (not tested), source:
https://github.com/XKEYGmbH/ifresco-client/tree/master/vendor/friendsofsymfony/jsrouting-bundle/FOS/JsRoutingBundle/Resources/doc
The jsrouting-bundle folder is a Git submodule. A Git submodule is actually a reference to another Git repository. This is why you cannot add changes from it to your original Git repository.
I had to do this in the past, here is what I did:
php composer.phar selfupdate
php composer.phar update
In the vendor directory run sudo find . -type d -name .git | xargs rm -rf
Commit all modifications: git add -A .
With this, your vendor will be commit like the src directory, so no need to run composer install when deploying in your production environment. When wanting to update just repeat the process. But of course it isn't a good practice and you should do this only if you can't run composer on your production server.

Overwriting files on local disk from github (using Laravel framework)

I'm trying do to the following:
1) Create a new laravel project using:
sudo composer create-project laravel/laravel /var/www/html/laravel5`
2) Overwrite only the different files from github. I want to keep the following files and folders unchanged:
.env
.env.example
.gitattributes
.gitignore
vendor/
Clone from github is not working because the folder is not empty.
The only workaround that I found is:
create a new project
copy the files and folders that I want to another folder
clone the project from github
copy the files back to the folder
I'm using Xubuntu, Laravel 5.0 and Github.
Thanks in advance.
You should be able to do this via an all-git method rather than copy/paste from another directory. (I'm not sure why your workaround is a bad solution, though.)
The basic plan is:
Create a repository.
Checkout some bogus branch that you won't keep around.
Add the directories you want to keep to the index and commit them.
Force a checkout to the branch you want. It probably will need forcing because of the other things you didn't just commit.
Apply the patch of the recently created commit to your working directory.
And in commands:
cd /path/to/repo
git init
git branch temp-branch
git add .env && git add .env.example && git add .gitattributes && git add .gitignore && git add vendor/
git commit -m "Sustain Local Changes"
git remote add origin https://github.com/owner/repo
git fetch
git checkout -f master # Should detect origin/master. If it doesn't, just set a branch up manually. Replace master if that's not the branch you want.
git merge --no-commit --no-ff temp-branch
Personally, I find this a lot more ugly than your workaround.

Install FOSUserBundle after cloning from Git

I've created my own site on my local computer and it works wonderfully. I'm having tons of fun developing with it. But when it came time to move it to my server and test I ran into issue.
I'm using the FOSUserBundle. Obviously being a Git of it's own, when I did a git commit and push, git ignored everything in vendor/friendsofsymfony/user-bundle. So when I cloned to my server, the folder came empty, and of course now my site doesn't work.
I want to do this the right way. So if it means destroying the git repo and doing it a different way, I'm ok with that.
So far I've tried.
Following the original install instructions for FOSUserBundle
Running the following:
composer update friendsofsymfony/user-bundle
composer install friendsofsymfony/user-bundle
Both return "nothing to update/install"
I've also tried clearing composer's cache between each command attempt.
rm -rf ~/.composer/cache
Answer is in the comments. Ignore vendor/ use composer to install the appropriate files.
also this Symfony project cloned with git vendors not installed
What it sounds like your trying to do is create a mywebsite parent repo within which you have a third party child repo that has the FOSUserBundle code. This uses git submodules and requires related submodule commands like git submodule init.
The ... directory is there, but empty. You must run two commands: git submodule init to initialize your local configuration file, and git submodule update to fetch all the data from that project and check out the appropriate commit listed in your superproject...
I don't know anything about composer. Here is how you could do it with git.
cd mywebsite
git init
git submodule add <url-to-FOSUserBundle-repo>
You should now have a directory structure like this:
mywebsite
.git
.gitmodules
FOSUserBunder
.git
See also http://git-scm.com/book/en/v2/Git-Tools-Submodules

Private git submodule not found in Jenkins

The problem
I'm trying to build my application in Jenkins, and it is on a private repo on Github, also there's a private submodule.
I can clone the private repository in Jenkins by setting up it's credentials, but Jenkins can't clone the submodule, here's the output of a failed build:
Started by an SCM change
Building in workspace /var/lib/jenkins/jobs/Project/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from git#github.com:user/repogit
using GIT_SSH to set credentials
Checking out Revision 9cc99b67cc676d0ea8ccd489a8327f5c6dbb8d7f (origin/branch)
[workspace] $ /bin/sh -xe /tmp/hudson2710403018107019432.sh
+ git submodule update --init --recursive
Initialized empty Git repository in /var/lib/jenkins/jobs/repository/submodule/.git/
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Clone of 'git#github.com:user/submodule.git' into submodule path 'repository/submodule/' failed
Build step 'Execute shell' marked build as failure
Discard old builds...
#156 is removed because status FAILURE is not to be kept
Publishing Clover coverage report...
No Clover report will be published due to a Build Failure
Sending e-mails to:
Finished: FAILURE
Here's what I've tried to do in Jenkins
Tried to set the Additional behavior "Advanced sub-module behavior", with no success.
Tried to set up a new step before running the tests with phpunit:
git submodule update --init --recursive
Tried to set a git repository on the project of my submodule too, not just the main repository that is being tested, no luck too.
All of them causes the error that says that Jenkins can't find the repository of the submodule.
Any ideas of how can I solve this?
(The username, paths and repositories are correct, I've just changed them to post here)
Solved. In my credential I was using a direct SSH key (option "Enter directly"), instead of putting into a file.
I've just put the keys (public and private) in ~/.ssh, and changed my credentials to the option "From the Jenkins master ~/.ssh".
The problem was that the submodule wasn't using the credential that I've specified to the main repository, it was trying to use the default ssh key (.ssh/id_rsa).
Another solution is to pass -i my_key to the git submodule step (only need this if your key isn't in the default path (~/.ssh/id_rsa) )
Also don't forget to give the correct permissions to your keys, in my case I had to:
chown apache ~/.ssh/id_rsa*
chmod 700 ~/.ssh/id_rsa*

heroku push rejected no cedar-supported app detected php - index.php present

I am trying to push my php app to Heroku and get the below error.
Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected.
I have read through all the previous posts which said that the PHP app should have a index.php in the root folder...which i do. When i do a "git ls-files" i get the index.php listed (with the name in lowercase).
steps i have performed so far are.
1. i have an application created on Heroku - stack:Cedar
2. git add the relevant files
3. git commit with a comment
4. git push heroku master -- this guy gives me the error.
git ls-files lists a file "index.php".
What am i missing this time?
I'm just starting out with Heroku and was encountering the same problem. Below is a description of what I did wrong.
Procfile
Make sure that the following statement is included in your Procfile:
web: vendor/bin/heroku-php-apache2 path/to/web/
Where path/to/web/ is the relative path to the directory that you want to publicly expose on the web. Make sure that the public directory contains an index.php file (e.g. path/to/web/index.php).
composer.json
In your composer.json directory (which should be in the base directory of the repository) make sure to include the Heroku PHP buildpack.
{
"require": {
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
If this statement was missing, then run composer update (./composer.phar update for me, because I downloaded composer and placed it in the base directory of my repository) so that Composer will fetch the package and install it into your vendor directory.
the issue was with an incorrect/incomplete .git directory. Deleting the old one and recreating it (git init) solved the problem.
try to run this on you heroku toolbelt
> heroku config:set BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-php
> git add .
> git git commit -am "add composer.json for PHP app detection"
> git push / git push heroku master

Categories