The following instructions walk through cloning a repository, creating a feature branch, and submitting a pull request.
You'll need to be ready to use git1 to follow along, and I suggest setting up ssh-key based authentication2 so you don't have to enter your username and password every time you are transferring code to and from GitHub.
# clone your repository
git clone git@github.com:repositoryName.git
# move into directory
cd repositoryName
# create a new branch
git checkout -b new-feature
# push new branch to origin (origin refers to GitHub in this instance)
git push origin new-feature
# make edits
# ...
# add work to the staging area for your next commit
git add file1.txt file2.png # etc
# write commit message
git commit -m "commit message here"
# push to origin
git push
# continue to make edits until the changes are ready to merge with main
# ...
# once ready for merging with main, pull any changes from main that may have occurred in the interim
git pull origin main
If there are conflicts, resolve and commit the merge, and push it to GitHub (e.g. "origin").
Open GitHub (e.g. github.com/repositoryName) and create a pull request when doing so, you can assign it to a team member to merge into main
Spot-checking is done at this point to make sure errors aren't introduced to the software.
If there's more to do before the new feature branch can be merged into main, we can put comments detailing the situation in the pull request as well as make additional commits to the new feature branch.
Once the commits of the new feature branch have been merged into main, the new feature branch should be deleted to keep the number of active branches to a minimum. There is a button on GitHub that appears after merging a branch, prompting you to delete it.
If you or other developers on your team use the Delete branch button on GitHub,
you should use git fetch -p
to prune the branches on your local machine to
match what is on origin.
Two more useful things: if you want to delete a branch on your local computer, you can do that with
git branch -d branch-name
or with -D
. If you want to rename a branch, that is done with
git branch -m old-name new-name
.
Here are some relevant references on git and GitHub:
- Pro Git https://git-scm.com/book/en/v2
- A successful Git branching model https://nvie.com/posts/a-successful-git-branching-model/