Git: Project Setup

You can setup git project using CLI commands, either manually or using an automated script.

Note

veritaspress is our project name that will be set up locally

Git Setup Script

For quick and automated Git repository setup, use the git_setup bash script with interactive prompts.

See also

For detailed installation instructions and the complete script, see Script 5: Git Repository Setup

The automated script provides:

  • Interactive prompts with input validation

  • Color-coded output for better readability

  • Automatic repository initialization

  • Remote origin configuration

  • Branch checkout with fallback handling

  • Git user configuration (name and email)

  • Complete setup summary

Quick Example

After installing the script from the bash service scripts guide:

# Navigate to project directory
cd /var/www/html
mkdir veritaspress
cd veritaspress

# Run the interactive setup script
git_setup

The script will prompt you for:

  • Git Repository URL

  • Branch Name (e.g., master, main, develop)

  • Git User Name

  • Git User Email

Then automatically configure your repository with all the necessary settings.

Manual Setup Using GIT Commands

If you prefer manual setup instead of using the automated script:

  1. Go to /var/www/html

  2. Create directory: mkdir veritaspress

  3. Execute following commands:

    cd veritaspress
    git init
    git remote add origin <git_url>
    git fetch
    git checkout master
    git config user.name "Your Name"
    git config user.email "your.email@example.com"
    
  4. Go to github, select the project and copy the github repository url:

    git project url

    Fig. 1 git project url

    Important

    Please change your url.

  5. Change composer version 2 to 1 : if require:

    sudo composer self-update --1
    
  6. Run command:

    composer install
    
  7. Add env.php file to app/etc/env.php

  8. DB import

    • Remove definer:

      grep "DEFINER" your_database_file.sql -rsn
      find your_database_file.sql -type f -exec sed -i 's/DEFINER=`root`@`localhost`/ /g' {} +
      
    • Create DB : veritaspress

    • Login mysql using cli. Here, root is username and secret is password:

      mysql -uroot -p  ## mysql username is root
      Enter password : secret ## Here my password is secret
      
    • Import db using SOURCE command:

      SET FOREIGN_KEY_CHECKS=0;
      use veritaspress;
      SOURCE cw_m2_LIVE_2022-06-09_09-27-25.sql;
      SET FOREIGN_KEY_CHECKS=1;
      
  9. Update base_url in core_config_data table

  10. Run all magento commands and check functionality

  11. Add pub/media directories