Git workflow
When working on a Git project, it's helpful to know what the steps are to publish your code and make everyone's life nice and smooth. Here's a quick step by step when you write your code.
Getting started
You should have set up an SSH key on the machine you are working on, if you haven't - follow the tutorial that SCC have provided us with.
Clone the project with git clone [PROJECT URL]
and use the SSH address provided.
When programming
ALWAYS use git pull
to refresh any changes made by others, you always want to keep your repository and corresponding branches up to date.
NEVER push your changes to the main
branch!
Other branches exist for you to develop your features into, which can be merged into main later.
Change your branch
Each feature should be developed in its own branch - switch to the branch you are working on with git checkout [BRANCH NAME]
Step-by-step
When you have written code, tested it and it works, make a commit.
Commits should be frequent and work, so make sure your code works before you commit.
To commit: use git add [filename]
for however many files you want to add in the same commit. (Remember to save the files before adding them)
Then use git commit -m "Commit message"
to create the commit, for the commit message, give a brief overview of what you have done, if you need more space, you can always press "enter" before you end the quotes to make a new line.
git add readme.md
git commit -m "Updated readme
>
> Readme now has more info to read in it"
Example commit
When you have made your commits, you need to push your changes to the server.
Use git push origin [NAME OF BRANCH]
to push them.