Hi guys,
how can i push my magento 2 code to git. can anyone guide me ?
Hello @safetyglass_saf
To push your code on git open terminal from your magento 2 root folder.
After that you have to first create a separate branch from master (or main branch). For this follow these commands :
git checkout master
git checkout -b new_branch_name
Now you are switched to a new branch but its only at your local system yet. Take pull from master to this branch and have to push this branch to main repository.
git pull origin master git push origin -u new_branch_name
Now you can modify your code and move to this branch using these commands.
/opt/lampp/htdocs/Magento2$ git status On branch new_branch_name Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: app/design/frontend/CustomTheme/Theme_name/Magento_Catalog/templates/product/view/form.phtml /opt/lampp/htdocs/Magento2$ git add app/design/frontend/CustomTheme/Theme_name/Magento_Catalog/templates/product/view/form.phtml /opt/lampp/htdocs/Magento2$ git commit -m "message related to change" /opt/lampp/htdocs/Magento2$ git push origin new_branch_name
Hope it will work for you.
If my answer is useful, please Accept as Solution & give Kudos.
As per my understanding, You already have a GIT repository . Where you want to push Megento code. Here are the steps you need to follow.
If you don't have git repository, create a git repository first. Use these steps to create:
Step 1: Create a GitHub account. The easiest way to get started is to create an account on GitHub.com (it's free).
Step 2: Create a new repository on GitHub
Step 3: Create a ReadMe file
Step 4: Make a commit
Step 5: Connect your GitHub repo with your hosting server
I hope this link will help you to setup a new repository on GitHub.
After setup a git repository. Here are the steps you need to push Magento 2 on GitHub:
Step 1: Clone GIT repository on your system
Step 2: Download a fresh Magento setup form here
Step 3: Extract the Magento installation zip file into the cloned directory
Step 4: Push all files of codes into GitHub
Step 5: These file will auto sync to server by GitHub.
I hope it will help you.
Thanks
--
if answer is helpful, Click Kudos & Accept as Solution