forked from lukeczapla/javacoderun
-
Notifications
You must be signed in to change notification settings - Fork 1
GitFlow Quickstart
Matthew edited this page May 13, 2021
·
10 revisions
Gitflow is a workflow that helps developers collaborate a seamless software development experience.
- In this quickstart, we will be borrowing from Gitflow but not following it completely
- If you are interested in the finer details, you can read about Gitflow here.
- Create a local branch that identifies you as the developer (e.g. mrodriguez)
- Push the local branch to track a remote branch on the server/origin
- Write code
- Stage changes of code you want to commit
- Commit the code to your local branch
- Push the changes
- Create a pull request
-
git branch <branch>- where
<branch>is the branch name of your choosing - this will automatically checkout (switch you to) your new branch
- where
-
git push -u origin <remote-branch>- where
<remote-branch>is the branch name on the server - good practice to choose the same name as your local branch name
- where
git push -u origin <remote-branch>-
git add <file>to stage files for commit a commit -
git commit -m "<commit message>"to commit staged files -
git pushto push local branch to remote branch
- Creating a branch in GitHub Desktop
- Publishing a branch
A pull request is a way for your changes to be merged into the trunk. It provides opportunity for review and feedback, thereby protecting the trunk from unreviewed code.
- If you pushed code to a remote branch the main page of the tamarisk repository should prompt you to create a pull request
- When you create a pull request make sure to select
marod424/tamariskas the base Base Repository, the branch to merge into as thebase: trunkand the base to compare as your branchcompare: <your-remote-branch>. - You can find all pull requests under the repo Pull requests tab
It is best practice to keep your local branch up to date. This means that you should regularly pull the latest code from the trunk into your local branch.
- Checkout the
trunk - Pull the latest code from the remote
trunk - Checkout your local personal branch that you want to keep up to date
- Merge the
trunkinto your local branch
git checkout trunkgit pull-
git checkout <branch>where<branch>is the name of your personal branch -
git merge trunk(merges your trunk into your branch)
Sometimes another developer is worker on the same file as you. If you try to merge changes that conflict with current work, you may need to manually resolve those conflicts.
- In this scenario you should have a conversation with the other developer in which you conflict if you are unsure whose changes should be committed
- Often you will need some combination of both your changes
- The process to resolve conflicts isn't always trivial, and is best done through GitHub or the GitHub desktop merge conflicts flow.
- Resolving a merge conflict on GitHub