In response to a lot of questions about how to work with git and GitHub when contributing to CSLA I wrote a blog post Simple Flow for Using Git and Pull Requests. That post is fairly long and includes explanations about why things work as they do.
Here's a tl;dr summary if you just want to get working without all the background.
I'm assuming the use of Git Bash or WSL command line. You'll need to translate if you are using cmd/ps1 or a GUI tool.
- Create a fork of MarimerLLC/csla using the GitHub web UI
- Go to
https://github.com/MarimerLLC/csla
- Click the fork button in the upper-right
- Go to
- Clone your fork to your dev workstation
- cd to directory where you want git to create a new
csla
sub-directory git clone https://github.com/yourname/csla.git
- Your GitHub fork is now known as
origin
within your local clone
- cd to directory where you want git to create a new
- Work in the
csla
directorycd csla
- Add an upstream remote so your local clone has access to the "real" main (not just your fork)
git remote add marimer https://github.com/MarimerLLC/csla.git
- The upstream GitHub repo is now known as
marimer
within your local clone
- Make sure your local clone is updated with MarimerLLC/csla
git fetch marimer
- Create a feature branch (work area) based on the upstream main
git checkout -b 123-feature-branch marimer/main
- Your local workspace is now in a feature branch based on the latest code in MarimerLLC/csla main
- Make sure your local clone is updated with MarimerLLC/csla
git fetch marimer
- Create a feature branch (work area) based on the upstream main
git checkout -b 123-feature-branch marimer/<maintenance-branch-name>
- Your local workspace is now in a feature branch based on the latest code in the maintenance branch
- Important: when you submit your PR (later in this doc) make sure the target of your PR is maintenance-branch-name, not main
- Edit code, and do other stuff
- Commit your changes to your local clone
git add .
- add all new/modified files to the git indexgit commit -m '#123 your comment here'
- Rinse and repeat as you work
- It is a good idea to commit frequently so you can roll back to a previous state in case of badness
- Committing only updates your local clone, it has no impact on anything in the cloud until you push (next step)
- Watch for changes from marimer/main
git fetch marimer
- will fetch changes from marimer. This does not update your local branch. It only updates your local repository.git log ..marimer/main
- will log all commits that have been made to marimer/main that are not in your branch. This can tell you if you need to update your branch. If there are no incoming changes, this prints nothing and there is no need to do the next step.git pull marimer main
- will update your local branch with changes that have been made to marimer/main. This is how you keep your local branch up to date.
- Push your local clone to your GitHub fork
git push origin
- Your GitHub fork now has a copy of your feature branch from your local clone
- You can push your local clone to GitHub as often as you'd like, this acts as a backup, and allows for collaboration (other people can see your changes via the GitHub web UI)
- Make sure your feature branch is current with MarimerLLC/main
git pull marimer main
- That may result in a need to merge changes; resolve any merge conflicts
- Make sure your updated/merged feature branch still builds
- Make sure your unit tests still pass
git push origin
- Create a PR from your GitHub fork to MarimerLLC/csla
- Use the GitHub web UI to create a PR from your fork to MarimerLLC/csla
- Navigate to your fork and branch in GitHub, then click the button to create a pull request, the defaults should be correct
- Double-check to make sure MarimerLLC/csla-main is on the left, and yourname/csla-yourbranch is on the right
- Creating the PR will trigger a CI build
- We will only accept a PR if it can be automatically merged (green checkmark)
- We will only accept a PR if the build/tests all pass (green checkmark from CI build)
- Your PR has no effect on main or production, it is a pending change
- Subsequent changes to your feature branch in your GitHub fork automatically become part of your PR; each time you push to your GitHub fork's feature branch triggers a CI build of the PR
- People can comment on, or review your PR, indicating changes you need to make before it is accepted
- This is a dialog so please engage with the reviewer(s) as appropriate
- Edit code or other stuff in your feature branch on your local clone
- Commit your changes to your local clone
git add .
git commit -m '#123 your comment'
- Push your local clone to your GitHub fork
git push origin
- Any changes pushed to the feature branch in your GitHub fork are automatically incorporated into your PR (and a CI build is triggered)
- Remove feature branch in your GitHub fork
- Use the GitHub web UI to remove the feature branch
- Remove feature branch in your local clone
git checkout main
(switch out of the feature branch)git branch -D 123-feature-branch
I'm not going to repeat all the commands here - they are the same as the steps above, but using your GitHub repo as the "upstream" instead of using MarimerLLC/csla as the upstream.
- Have other person create a fork from your fork using GitHub web UI
- Have other person clone their fork to their workstation
- Have other person add your fork as an upstream remote to their local clone
- Have other person update their local clone from your fork
- Have other person create working branch based on your feature branch
- Have other person do their code or other changes
- Have other person commit changes to their local clone
- Have other person push their local clone to their fork
- Have other person create a PR from their fork to your fork
- Accept their PR to merge their changes to your fork's feature branch (which automatically updates your PR and triggers a CI build)