Hosting Prestashop, Magento y WordPress listo para usar, optimizado y con mejoras exclusivas. Soporte especializado, servidores en España
Chat
¿Hablamos?
There was a problem loading the comments.

GIT Basic Guide

Support Portal  »  Knowledge base  »  Viewing Article

  Print
# Basic concepts

  • Never work under the master branch
  • Always create a new branch for each task and keep it updated with master.
  • Have the server clean of files to be shared, which will allow a better management and analysis if any file has been changed.

# Clone GIT
- git clone

# Check GIT status
- git status

# Change branch
- git checkout

# Get changes made to branch
- git pull origin

# List files
- git ls-files

The command is useful to add deleted files when there are also modified ones:
- git ls-files --deleted // I would list them
- git rm $(git ls-files --deleted) // Mark all deleted ones as such to apply the commit

# Add files
- git add // Relative path or else "." to add all those in git status
- git rm // If we wanted to add a deleted file to be removed in production we would have to use this command
- git commit -m "message" // Message referencing the changes of the files included by git add
- git push origin // Normally we will have a specific branch to develop certain tasks,
// the naming is suggested to be something that identifies the development to be done. For example, to install the Magento SUPEE-7777 patch, it could be: install-patch-SUPEE-7777 or SUPEE-7777

# Remove branches
If by chance we have created a branch locally that we want to remove without removing the origin branch:
- git branch -d


If we want to remove it from origin (we could break code, this step should not be needed in a logical workflow), any of these options would be useful:
- git push origin :
- git push origin --delete

# View changes made to a file
- git diff // Without parameter makes a comparison of all modified files

#Integrate changes with master
When we finish our development and have tested it we can integrate our branch with master. The best thing to do is to have someone review our commits before uploading them to master.
To do this we would follow the steps as follows:

We will switch to the master branch and make sure it is updated, for this:

- git checkout master
- git pull origin master

Once this is done we switch to the branch we want to upload:

- git checkout

To migrate the changes we will use the command:

- git merge master

This way we will get the changes from master to our branch. If our development is long we should perform the master merge on our branch continuously to avoid finding conflicts.
We can now commit the changes and upload them to our branch:

- git push origin

We go back to master and merge our branch, as we will have merged it previously we will not have conflicts when performing the merge. We will always avoid conflicts in the main branch:

- git checkout master
- git merge
- git push origin master // Upload to master

Once this is done, in the server or the production page we can perform a data collection of master to keep it updated, always making sure that we are under master:

- git checkout master

-gitpull origin master

Si todavía tienes dudas, contacta con nosotros y te ayudamos.


Share via
Did you find this article useful?  

Related Articles


Comments

Add Comment

Replying to  


Self-Hosted Help Desk Software by SupportPal
© FactoriaDigital.com