How to install Git for Magento?

In fact, there are many pages that allow you create Git repository like Bitbucket, GitHub, GitLab, etc. However, in this post, we will show you the way to setup Git on http://bitbucket.org

Let’s start!

Step 1:

Login (If you had Bitbucket account) or create a new account on http://bitbucket.org

Step 2:

Create a Repository by tap Repositories> Create repository

Step 3:

Login SSH

There are 2 ways to use Git via https link or ssh

  1. Use Git via https link
  • cd code_storage_folder : go to folder including code
  • git init : create a init for Git
  • git remote add origin link : get link from clone https on Bitbucket and copy from http:// to the end of this link
  • vi .gitignore : create (if you’ve had .gitignore file) or edit .gitignore file to ignore the unnecessary folders like var/, app/etc/local.xml, media.catalog/product/cache, etc.
  • Besides, you can add more folders of Magento system as app/etc/modules/… (however, we recommend you should not add these files because there are many modules added directly into them
app/code/community/Phoenix/

app/code/core/

app/design/adminhtml/default/default/

app/design/frontend/base/

app/design/frontend/default/default/

app/design/frontend/default/blank/

app/design/frontend/default/iphone/

app/design/frontend/default/modern/

app/design/install/

app/etc/modules/Mage_All.xml

app/etc/modules/Mage_Api.xml

app/etc/modules/Mage_Bundle.xml

app/etc/modules/Mage_Centinel.xml

app/etc/modules/Mage_Compiler.xml

app/etc/modules/Mage_Downloadable.xml

app/etc/modules/Mage_Weee.xml

app/etc/modules/Mage_Widget.xml

app/etc/modules/Phoenix_Monkeybookers.xml

app/etc/config.xml

app/etc/local.xml.additional

app/etc/local.xml.template

app.locale/en_US/

app/Mage.php

cron.php

cron.sh

downloader/

errors/

favicon.ico

includes/

index.php

index.php.sample

install.php

js/blank.html

js/extjs/

js/lib/

js/prototype/
  • git add . :
  • For the first commit (in the following commits, you just need to add files changing content, git status to see the changes)
  • For the first time you use Git, the system will require you to configure some information. Below are some common configurations you will meet in the first time using Git:

+ git config core.fileMode false (ignore the changes about chmod)

+ git config –global user.email “example@gmail.com” (email you use to register on Bitbucket)

+ git config –global user.name “username” (optional)

  • After configuring, you continue with commit

git commit –m “first commit” : create commit to push to Bitbucket with the name inside “ “

git push origin master : push the commit to Bitbucket

  1. Use Git via ssh

It is more security with this way but you will have to do more.

  • Move to /Users/Admin/.ssh folder and then use command Is –a .ssh to check out whether your device has .ssh key or not. .ssh key is be like:
id_rsa

id_rsa.pub

id_dsa.pub

id_ecdsa.pub

id_ed25519.pub

If the .ssh key has not existed, you have to create new one:

 ssh-keygen –t rsa –b 4096 –C “example@gmail.com”
  • Tap Enter when the system ask you where will you save .ssh key
  • Enter the password for the key
  • Add key into ssh-agent:
eval “$(ssh-agent –s)”

ssh-add ~/.ssh/id_rsa
  • Add ssh public key into Bitbucket account:

cat ~/.ssh/id_rsa.pub |clip (this command is used to copy the content of id_rsa.pub)

  • Login to Bitbucket account and paste the content into Add ssh key at Bitbucket setting
  • Check out whether the key is added or not
ssh –T git@bitbucket.org

If it display logged in as username, it means the key was added successfully

  • cd code_storage_folder (access folder including code)
  • git init (create a init for Git)
  • git remote add origin link (you get the link from clone https on Bitbucket, copy from git@bitbucket.org to the end of this link)
  • The next steps you will do as same as the way you perform with link https:
create .gitignore

git add

git config (if it is necessary)

git commit

git push

We’ve given you 2 ways to install Git for Magento on Bitbucket. If you have any questions, contact us for the answers.

Thanks for reading!

>> See more Magento tutorial