I’ve been trying to get more proficient with git and figured the only way to do that is to get my hands dirty and write some simple app(s) and push them to a production server. There are my notes, mainly for me to help me remember how this stuff works.
The very first time you do a git init to initialize your repository.
git init
You do this every time you want to add new changes to your reposiotry.
git add .
To see the status of things which are going to be added, removed.
git status
Once you’re happy with what you want to commit, leave your future self a little love note.
git commit –m “Doing something”
You only do this the first time to setup your remote repository destination.
git remote add origin git@github.com:dmaciasSS/myrepo.git
Then you do this every time you want to push your commit.
git push –u origin master
—
Now, let’s say I want to pull my repository to a new host e.g. production. If you’re using Laravel make sure you’re setting up your environment name in your vhost file first.
sudo git clone https://github.com/dmaciasSS/myrepo.git locaton/in/my/server
Laravel specific commands.
chown -R :www-data app/storage
chmod –R 777 app/storage
‘composer install’
php artisan cache:clear
I’ve found for 5.1 you might have to do this the first time too.
mkdir storage/views
mkdir storage/sessions
chown –R :www-data app/storage
—
Now, once you’ve cloned your repository you need to updated it every time you want to pull down any new commits.
sudo git pull origin master
composer update
php artisan cache:clear
~david