Commands

Clone

You’ll clone a project when you use it for the first time. The directory name is optional - this gives you the opportunity to set a specific directory name should you need to.

git clone [repository] [optional directory name]

Dev remote

This command will be provided when you first start the project. You will need to run command only once and sets the destination when pushing to dev.

git remote add dev [repository URL]

Push/pull process

It's important that we maintain the same process when working on a repository with others, therefore it is recommended that the following commits are run every time:

  1. git pull origin master - to retrieve the latest commits (if any)
  2. git add * - to add all changes to the subsequent commit
  3. git commit -m 'Meaningful commit message here' - to provide a commit message following the above guidelines
  4. git push origin master - then to finally push the changes to the relevant repository

When pushing to dev the process is very similar, the first thing to remember is to make sure you have added the repository URL for the dev build. Once you have done this you only need follow the same process as you would to push to origin, but in the fourth step will need to replace origin with dev.

git push dev master

it is also important that the dev is pushed after a push to the origin is done. With the use of '&&' you can queue up these commands.

git push origin master && git push dev master

Git Conflict Resolutions:

If there is a conflict this means you and someone has worked on the same file(s) and the changes can not be separated normally. Before pushing you should also pull to avoid some merge conflicts where you have tried to push when you are a commit behind the master.

Sometimes there isn’t much you can do about avoiding this so you can follow these steps:

  1. Pull the master and see if there is a conflict if so then check what files have conflicts in them. NB - If the file that is conflicting has changes that you did not make or mean to you can revert that specific file with git checkout @ — {file_location} (This can useful when it is changes to a file that is always compiled so your changes wont matter e.g. ‘public/js/app.js’)
  2. Then if you have a conflict you can store your local changes with git stash
  3. After this is complete use git pull origin master to get the latest changes, then: ⋅⋅* a. Add in your changes that you were working on with git stash apply —index - this will attempt to auto merge the conflicting files and use both changes ⋅⋅* b. If there is an error with this step then it normally means the conflict can’t be auto merged. To fix this you can go into the file and search for >>>> and will show you both your changes and the changes from the master
  4. Now you should be able to add your changes and push like normal