How to delete a Git brach locally and remotely by command
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
// delete branch locally
git branch -d localBranchName
// delete branch remotely
git push origin --delete remoteBranchName
We can inset from new row or run query as exampled below to insert new user to existing site. The md5 method of user registration can’t be decrypted. So we need to create new user from query.
INSERT INTO wp_users
(ID
, user_login
, user_pass
, user_nicename
, user_email
)
VALUES (‘2’, ‘prakash’, MD5(‘password’), ‘Prakash’, ‘akash2046@gmail.com’);
INSERT INTO wp_usermeta
(umeta_id
, user_id
, meta_key
, meta_value
)
VALUES (NULL, ‘2’, ‘wp_capabilities’, ‘a:1:{s:13:”administrator”;s:1:”1″;}’);
INSERT INTO wp_usermeta
(umeta_id
, user_id
, meta_key
, meta_value
) VALUES (NULL, ‘2’, ‘wp_user_level’, ’10’);
php artisan make:model Flight
php artisan make:model <folder_path>/Flight
php artisan make:model <folder>/Flight -m
php artisan make:seeder ModelNameSeeder <modelName>
Run Specif file with defining Path::
php artisan migrate --path=/database/migrations/my_migration.php
php artisan db:seed ---> Run Full Seeder
php artisan db:seed --class=UserSeeder ---> Run Specific Seeder <user>
php artisan migrate:fresh --seed ---> Run Migration with Seeder
php artisan db:seed --force ---> Force Full Seeing db
There are Git Command line which are use full for developer.
Additionally, Git does not require any pre-existing server or admin privileges. All you have to do is cd into your project subdirectory and run git init
, and you’ll have a fully functional Git repository.
$ git init
We can set up repository on Remote Git servers like git-hub, git-lab, bit bucket etc.
Define Remote address:
$ git remote add origin https://github.com/PrakashKumarBhandari/projectname.git
Then push your project file into remote.
$ git push -u origin master
$ git config --global user.name "Prakash Bhandari"
$ git config --global user.email"akash2046@gmail.com"
Add Username and Email for sync remote and local data.
Show the remote path or git which is cloned or added origin::
$ git remote show origin
We can use Git clone command if we have already exiting project.
Sometime we get error on pulling local file to origin. error like that
the solution would be ::
The error is resolved by toggling the allow-unrelated-histories switch. After a git pull
or git merge
command, add the following tag:
git pull origin master --allow-unrelated-histories
$git clone <project_url>
-a
shows all local and remote branches, while -r
shows only remote branches.
$ git branch [ Show all local Branch]
$ git branch -a [ Remote and Local Branch]
$ git branch -r [ Show all remote Branch]
Git checkout remote branch lets us switch to (and work on) a remote branch, just like we’d switch to a local one. There are a couple of ways to do this.
First, fetch the remote branches:
git fetch origin
Next, checkout the branch you want. In this case, the branch we want is called “branchxyz”.
git checkout -b branchxyz origin/branchxyz
Or you can use:
git branch branchxyz origin/branchxyz
With newer versions, you can simply use:
$git fetch
$git checkout branchxyz
To rename a branch, run the command:
$git branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME
# Alternative
$git branch --move OLD-BRANCH-NAME NEW-BRANCH-NAME
Git won’t let you delete a branch that you’re currently on. You first need to checkout a different branch, then run the command:
$git branch -d BRANCH-TO-DELETE
# Alternative:
$git branch --delete BRANCH-TO-DELETE
You can compare branches with the git diff
command:
$git diff FIRST-BRANCH..SECOND-BRANCH
//Clear route cache:
Route::get(‘/route-cache’, function() {
$exitCode = Artisan::call(‘route:cache’);
return ‘Routes cache cleared’;
});
//Clear config cache:
Route::get(‘/config-cache’, function() {
$exitCode = Artisan::call(‘config:cache’);
return ‘Config cache cleared’;
});
// Clear application cache:
Route::get(‘/clear-cache’, function() {
$exitCode = Artisan::call(‘cache:clear’);
return ‘Application cache cleared’;
});
// Clear view cache:
Route::get(‘/view-clear’, function() {
$exitCode = Artisan::call(‘view:clear’);
return ‘View cache cleared’;
});
$ git config --global user.name "Prakash Bhandari"
$ git config --global user.name
> Prakash Bhandari
$ git config user.name "
Prakash Bhandari
"
$ git config user.name
> Prakash Bhandari
Step 1:
We need to clear the config file at first. It has previous configuration on that file. delete or name that file.
<site_folder>/bootstrap/cache/config.php
Step 2:
Rename server.php
in your Laravel root folder to index.php
Step 3:
Copy the .htaccess
file from /public
directory to your Laravel root folder.
Add Code into Htacces file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
As many of you know, I am a huge Pantheon hosting fanboy and can still remember the days during the beta launch of being blown away that I have three different environments out of the box, with dev, test and live. Another great service they added recently is that all sites receive SSL certificates automatically and all you have to do is redirect all traffic to use HTTPS. In Drupal 8 they suggest doing this in your settings.php file.
After adding the redirect code everything works great until you fire up your local environment (I am currently using Lando) and you are getting a blank screen. After further investigation, you notice it’s the redirect to HTTPS that is causing the issue. My first thought was to make sure my settings.local.php file was correctly being used but for the life of me, I could not get that file to override the redirect code in my settings.php file. If you are reading this and have a better idea on to how to accomplish this then let me know in the comments 🙂
My next thought was to simply add the settings.php file to my .gitignore file but when I went to my production website I was prompted to reinstall my Drupal site. When adding a file to .gitignore the repo pretends it doesn’t exist so therefore Drupal was telling me to reinstall. Whoooops, my production site kind of needs this file hahahah. So I thought to myself,
After attending Google University for 10 minutes, I stumbled upon a medium post by Ian Gloude regarding the git update-index
command. In their article “Git skip-worktree and how I used to hate config files,” there is a great explanation of the concept, but for me the lightbulb really went off when reading the Git documentation hint, “see also git-add[1] for a more user-friendly way to do some of the most common operations on the index.” Basically git update-index
tells Git what to watch in your repo.
Now that we understand what git update-index
does, the real magic happens with the options that you can add to the command. In this case, the option that Ian Gloude suggested is the --skip-worktree
option. The Git documentation explains that the skip worktree bit tells the git index to assume the file is unchanged from this point on regardless if there is an actual change. So what does this mean for us? It means you can change your file on your local environment while the original file on your production server remains unchanged.
Here is the command I use prior to uncommenting out the pantheon redirect code.
git update-index –skip-worktree /sites/default/settings.php
When I need to make some changes to the production settings.php file I can tell Git to watch the file again with this command.
git update-index —-no-skip-worktree web/sites/default/settings.php
Anyway, I hope this helps you keep your local and production environments running smoothly while maintaining your settings differently.
There are times when you have a large number of users and you need to update or notify them simultaneously via SMS. Maybe you run a membership site or personal blog. Whatever the case this tutorial will provide an efficient and easy way to achieve sending bulk SMS via your web app.
For this tutorial we’ll assume you already know or have the following:
Just in case you don’t have a Laravel project setup, this guide will help you to create a new Laravel project locally.
The first thing we need to do is install the Twilio Laravel SDK which will provide the needed functions to get our bulk SMS app started. We’ll use the command line to achieve that. So in the command line type:
$ composer require twilio/sdk
Now that we have the SDK installed, we need to configure it to recognize our Twilio account. Open up your .env
file and paste in the following code. Be sure to replace the variables with your Twilio credentials. TWILIO_FROM
is your Twilio Number.
TWILIO_SID=ACXXXXXXXXXXXXXXXXXXX TWILIO_TOKEN=XXXXXXXXXXXXXXXXXXXXX TWILIO_FROM=APXXXXXXXXXXXXXXXXXXX
We need a controller specially for our BulkSMS app, so paste in the command below to create a controller using Laravel’s artisan console.
$ php artisan make:controller BulkSmsController
Open the controller and include the Twilio class at the top:
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Twilio\Rest\Client; use Validator;
Next we will create a view file called bulksms.blade.php
to make an HTML form to create the necessary fields for our bulk SMS app.
$ touch resources/views/bulksms.blade.php
Open up the newly created file located at resources/views/bulksms.blade.php
and paste in the code below:
<html> <body> <form action='' method='post'> @csrf @if($errors->any()) <ul> @foreach($errors->all() as $error) <li> {{ $error }} </li> @endforeach @endif @if( session( 'success' ) ) {{ session( 'success' ) }} @endif <label>Phone numbers (seperate with a comma [,])</label> <input type='text' name='numbers' /> <label>Message</label> <textarea name='message'></textarea> <button type='submit'>Send!</button> </form> </body> </html>
Laravel will run <domain-name>/public folder but we can remove this public path from our site with
server.php
in your Laravel root folder to index.php
.htaccess
file from /public
directory to your Laravel root folder.It will run site in <domain-name> with out /public but some assets js, css will not work properly we need little bit htacess changes.
these changes are :