Git setup in local and live server

If multiple members are simmontenniously working on a project in Magento, it feels difficult to work together so we need a tool to manage the files when multiple members work on the same files or file system. So we use GIT as a solution for the same.

Git management in Magento2 projects.

  • Install magento in the locale.
  • Init git on the local magento2 folder using command
    git init
  • Once the git init command has been done. Two files will be generated.
    1. .git folder
    2. .gitignore file
  • In the git ignore file add the files to be ingnored on the file structure on the locale.
  • On the same time we need a git repository to store the files in the git. Setup the same.
  • Link the git repository with the the local by using command.
    git pull origin main
    Here origin is the git repo. Some times we will get an error that origin not defined or found. So for the same setup origin using a command. Replace the last word with git repo link.
git remote add origin git@github.com:User/UserRepo.git
  • Checkout to a new branch
    git checkout -b branchname origin/main
  • Once all these done, push the files to git. Using command
    git add *
    git commit -m “commit comment”
    git pull origin main
    git push origin branch name
  • The push command will generate a MR request.
    through merging this in the browser the files will be pushed to git.
  • To fetch the git files to server… Do the same
    Initialise the git.
    Then connect the origin
    Then pull the files from repo.
    Do composer update.
    Check the config.php and env file in the app/etc folder
    Do the basic magento2 commands Upgrade, Deploy, Compile.

The git management can able to do through these.

Leave a comment

Your email address will not be published. Required fields are marked *