GitHub collaboration - gy315-K/REAL_FORKED_abT-Tact-cells-Team2 GitHub Wiki
- Master branch should always be deployable (here the “master” refers to the one from Alexander Sasse)
That means to NEVER work directly on the master branch, but to always create new branches for new features and work on those
- STEP 1: Fork the repo
Go to the original repo page Click the “Fork” button in the top-right corner Creates your own copy of the repo (I’ll call it “forked master” in this summary for understanding)
- STEP 2: Clone the FORKED repo to your local Github desktop
Add the following code to command prompt: “git clone https://github.com/yourname/project.git cd project”
- STEP 3: Add the original repo as a remote
It will help keep the fork in sync with the original, code: “git remote add upstream https://github.com/originalowner/project.git” then fetch updates from the original repo with: “git fetch upstream git merge upstream/master”
- STEP 4: Create branches
A branch should always always always represent features Pick features that don’t have overlapping code Use new branches for every task
If tasks build on each other make branches from the previous branches, what I mean is: if task 2 builds on task 1, make a branch from branch 1 If task 2 is unrelated to task 1, make a branch from “forked master” BUT ALWAYS MAKE BRANCHES
- STEP 5: Submitting pull requests
One person should be in charge of handling merging -> “Reviewer” or “Merge Master” Everybody should git push their branches:
Go to Github Repo page Pushed branch should appear in a yellow bar at the top of the page with the button “Compare and pull request” -> click on that You’ll be redirected to the “open a pull request” page Write a brief description of what was actually changed Click the “Reviewers” tab and select whoever the team “Merge Master” is Then click “Create pull request”
Rebase the branch: putting your changes on top of the latest version of the main branch, helps to avoid messy merge commits
To catch up cleanly, put the following code in the command prompt when pushing branches: “git fetch upstream git rebase upstream/master” Moves work on top of the latest upstream “forked master”
Squash commits before pushing: means combining multiple commits into one
When you make multiple commits in your branch, you’ll get a list looking like, example: “pick a1b2c3 Added login page pick d4e5f6 Fixed bug pick 789abc Updated CSS …” Change all but the first “pick” to “squash”, so in the example: “pick a1b2c3 Added login page squash d4e5f6 Fixed bug squash 789abc Updated CSS …” Git lets you write a new combined commit message and push with: “--force git push -f” This overrides the single commits and combines them in one, useful if for example you saw and corrected a mistake after the first commit and want to change it before pushing to the “forked master”
For the “Merge Master”/”Reviewer”:
You’ll notice a notification that something has to be reviewed -> “ [somebody] requested your review on this pull request” Click the “Add your review” button You’ll be redirected to the pull request page Best option is to go through pull requests together with the whole team When satisfied, go to the bottom and click “Merge pull request” You’ll see a “pull request successfully merged and closed” message and a button “delete branch” which should be clicked
Generally: DON’T TRY TO MERGE MORE THAN ONE BRANCH AT A TIME