Reputation: 21
I'm developing a new Magento and I need to install GIT as version control, but I'm pretty new using GIT, so I'm trying to find a way to complete this integration.
I have two environments created: Stage which is hosted on a sub-domain (example: stage.domain.com) and Production which is hosted on the main domain (example: domain.com) Both environments are identical, both have the same files and database.
What I want is to be able to deploy new changes as follows:
connect to Stage site via SSH connection, create new "feature branch" as feature/[branch-name], make desire changes, add and commit these changes to this new branch.
push this new branch into origin, which would be the remote repository created on Bitbucket (git push origin feature/[branch_name])
checkout "develop branch", do git pull, merge origin/feature/[branch-name] into develop, and push these changes.
checkout "master branch", do git pull, merge origin/develop into master, and push these changes.
After doing these 4 steps, Master branch would be updated with the new changes, so after that, all I want to do is to connect to Production site via SSH connection and just do:
git status git pull
That would be all, this the way I'm handling a deployment process for another client that I have(but I wasn't the one who configured it), so I just want to use this same "work-flow" for this new Magento site that I'm developing.
It would be great if someone can share a step by step guide in how to complete this integration from scratch(installing GIT, running specific commands, cloning remote repository, etc...)
I will appreciate your help on this. Thanks!
Upvotes: 1
Views: 157
Reputation: 71
Install GIT For window: Install GIT software from one of the below URLs. https://git-scm.com/download/win https://www.sourcetreeapp.com/
For Ubuntu: sudo apt-get install git
Configure GIT account on your system Open git command console and run two commands. Replace email and username of your git in the command. git config –global user.email “email address” git config –global user.name “password”
Clone GIT branch This is the first command to initialize the project
Go to GitHub Go to branch from where you want to clone Click on ‘clone or download’ button Copy ‘clone with https’ URL e.g. https://github.com/……../…….git Create a directory on your system and go to the new directory Run under command: git clone https://github.com/……../…….git
GIT checkout You can switch one branch to another branch eg. git checkout dev[branch name] git checkout design
GIT Add You can add file to GIT git add.
GIT commit git commit -m ‘added files’
GIT Push Push the branch on git : git push origin [name_of_your_new_branch] eg. git push origin dev
GIT Pull Pull the changes from git to your system : git pull
GIT Remove git rm filename Please don’t remove file or folder without git commands.
List Branches You can see all branches created by using : git branch
GIT Status This is the very very useful command, so you can use this command before using any command to know exactly where are you. To heck updated code and also confirmation of which branch you stand git status
Git command for testing with sequence – git init – git clone – git checkout branch_name – Add test file like test.txt – git add. – git commit -m ‘add test file’ – git push origin branch_name – Put username and password of git when asked – Check new added test.txt file on branch of git
Upvotes: 0
Reputation: 21
I have solved the problem. I have initiated Git on production, I have pushed it to the remote repository, then initiated Git on Stage and I have cloned it from the remote repository, that was all. I have a guide with the correct commands in case someone needs it.
Upvotes: 1