git Guide
Some important rules
- Don't commit directly to master
- We follow something similar to git flow, but more simple:
- When working on a new feature, we will create a new 'feature branch'
- Feature branches should be discrete work items
- When you are ready for feedback on your feature branch, open a pull request. When some or all of the team are satisfied with your changes, we will approve this and merge it in (if there are no conflicts)
Helpful commands
Command | Description |
---|---|
git status |
Prints the status of your current git workspace (uncommitted changes, uncommitted files, staged changes, staged files, changes ready to be pushed/pulled, etc.) |
git fetch |
Fetches new data from the remote |
git pull |
Fetches new data from the remote and attempts to merge changes into your local branch from the corresponding remote branch (if there is one) |
git checkout <branch-name> |
Switches your local git workspace to the specified branch |
git checkout -b <branch-name> |
Creates a new branch, <branch-name> and switches to it |
git add [-A] <src> [<src2>, ...] |
Stages files for commit -A - Include newly created files <src> - Path to file(s) you wish to stage for commit (e.g. . ) |
git commit -m "<message>" |
Creates a new commit with specified message <message> |
git push -u origin/<branch-name> |
Creates a new remote branch <branch-name> and pushes the current local branch to it I recommened you use the same name as your local branch or risk confusing yourself Only use this command if the remote branch does not yet exist, otherwise just use git push |
git push |
Push your local commits to the corresponding remote branch (if existing) |
git merge origin/master |
Merges the remote master into your current branch Make sure you git fetch first so you have the latest changes You may run into conflicts doing this and if this happens, don't hesitate to contact me so I can help with resolving them |
git stash |
'Stashes' your local uncommitted/staged changes |
git stash pop |
Pops your last 'stashed' changes off the stack and into your current branch |
Additional
If you have any additional questions, do not hesitate to ask.
If you run into any problems with git
, I would recommend asking if you're unsure as some git
commands I haven't listed here have been left out intentionally because if you're not very familiar with command line git, you have the ability to lose changes or other worse things.
Please note that as this was written for team members of a group assignments, I would suggest looking elsewhere if you are looking for further
git
help. There are far more useful resources available with a quick Google search for assisting with any issues you may come across yourself.Please do not contact me with general requests for git help.