-
Notifications
You must be signed in to change notification settings - Fork 0
Source Control Workflow (Git)
We will use three distinct remote branches during development:
- master - Code in production used by the public
- staging - Production ready code, coming in next release
- dev - Newly developed features, moved to staging once tested
As well as 2 local branches:
- dev - connection to remote branch
- my_local_branch - where you develop all your code, choose the name
You develop on my_local_branch (call it whatever you want), and merge into dev when you want to push new code/features. Once tested, make a pull request into staging, which should always contain the new production-ready code. Once we want to publish on app stores, we will merge staging into the master branch after thorough testing our building.
First things first, you need to clone your repo. To do that, copy paste the HTTPS URL and enter the command:
git clone <HTTPS URL without braquets>
You will probably need to enter your GitHub credentials. Once the repo has been cloned, make sure you switch to the dev branch before starting your implementations
git checkout dev
git branch // make sure you see dev and master in the resulting print
From here, set up your dev branch. To create and switch to a new branch:
git checkout -b my_local_branch
You are now all set for development. Feel free to use git status as much as you want to see the progress of your changes. When ready to push changes, refer to the section below.
Note: You can simply develop on local dev branch if you'd prefer, but merge conflicts might be trickier for you to fix. Depends on your comfort level.
When you are done with a feature/bug and want to update dev, prepare your local dev with your changes.
To do this, make sure all your changes are committed to my_local_branch. Then switch to dev, make sure you have the most recent version, and merge your local branch into it:
git checkout dev
git pull //should say All up-to-date
git merge my_local_branch
Then, if the merge is successful, push to remote dev*.
git push
*For consistency, you may want to delete your local branch and re-create it from dev, but that's up to you
All work should be done on your local branch (my_local_branch). Please use descriptive commits.
To check the status of your files (your most common command):
git status
To create a new local development branch:
git checkout -b my_local_branch
To prepare a new file to be included in a commit:
git add your_file_name.txt
git add * --> this adds all new untracked files (if not included in .gitignore)
To commit changes to a branch:
git commit -m "Your message here, include quotes around this text"
To change to a specific branch:
git checkout my_branch_name
To delete a local branch:
git branch -D my_branch_name