Please ensure that you have Git & GitHub CLI installed by running:
git --version
gh --version
We will be using package managers to install git, so we do not need to deal with any installation wizards!
For Windows 11 users, run:
winget install -e --id Git.Git
For Mac users please run:
xcode-select --install
For Ubuntu users, run:
sudo apt-get update && sudo apt-get install git
If you were unable to install with one of the options above, please install through the git website
If this is your first time using git, you will need to set up your username and email.
Configure your username by running:
git config --global user.name "<Your Username>"
Configure your email by running:
git config --global user.email [email protected]
gh
is available via [Homebrew][], [MacPorts][], [Conda][], [Spack][], and as a downloadable binary from the [releases page][].
Install: | Upgrade: |
---|---|
brew install gh |
brew upgrade gh |
Install: | Upgrade: |
---|---|
sudo port install gh |
sudo port selfupdate && sudo port upgrade gh |
Install: | Upgrade: |
---|---|
conda install gh --channel conda-forge |
conda update gh --channel conda-forge |
Additional Conda installation options available on the gh-feedstock page.
Install: | Upgrade: |
---|---|
spack install gh |
spack uninstall gh && spack install gh |
gh
is available via:
- our Debian and RPM repositories;
- community-maintained repositories in various Linux distros;
- OS-agnostic package managers such as Homebrew, Conda, and Spack; and
- our [releases page][] as precompiled binaries.
For more information, see Linux & BSD installation.
gh
is available via [WinGet][], [scoop][], [Chocolatey][], Conda, and as downloadable MSI.
Install: | Upgrade: |
---|---|
winget install --id GitHub.cli |
winget upgrade --id GitHub.cli |
Note
The Windows installer modifies your PATH. When using Windows Terminal, you will need to open a new window for the changes to take effect. (Simply opening a new tab will not be sufficient.)
Install: | Upgrade: |
---|---|
scoop install gh |
scoop update gh |
Install: | Upgrade: |
---|---|
choco install gh |
choco upgrade gh |
MSI installers are available for download on the [releases page][].
To add GitHub CLI to your codespace, add the following to your devcontainer file:
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
}
Login to GitHub using your account:
gh auth login
- Open Terminal / Power Shell and change directory into where you would like to store project and run:
gh repo clone codersforcauses/practical_software_engineering_practices
-
Pick an issue on the Issues page and assign yourself to it.
-
Create a new branch by running (please create branch with your name:
git branch <name of branch>
- To view all branches available (not on github), Run:
git branch
Now that we have created our branch, it is time we checkout(switch to) that branch so we can edit code!
- To change to the branch created, Run:
git checkout <name of your branch>
- Let push your newly created branch to github by running:
(name of remote will be origin for today)
git push <name of remote> <name of branch>
Please ensure that you are on the branch you have created before continuing further!
- Now that you are on your branch, you are free to do whatever you like with the code! For the excercise, create a copy of the template folder and rename it to your name. Run:
cp -r ./template/ ./<your name>
For this exercise, there is only 1 file that requires completion
addition.py
Lets start by correcting addition.py
, modify the code so that it looks like this:
def addition(a,b):
return a+b
After saving your file, it is time to add this to the staging area by running:
git add addition.py
Once you are happy with your changes, it is time to commit! Don't forget to leave meaningful commit messages! Commit your change by running:
git commit -m "your commit message"
After commiting, we still need to push our changes to GitHub. Push your changes by running:
git push origin <name of branch>
Now that you are satisfied with changes on your branch, we need to merge these changes with our main branch so that your changes can be added into the codebase. Head over to the pull request section to create a new pull request. In the description, add Resolve #<issue number>
to link your pull request to the issue you have been working on. The pull request may close the linked issue once it has been successfully merged. Be sure to delete your branch after your pull request has been merged.
There is no command for creating a pull request as a pull request is something that a cloud provider like GitHub, GitLab or BitBucket provide. It is not part of Git itself.
Once your code has been reviewed. Click squash and merge to merge your changes into the main branch.
Please leave any suggestions for future events or feedback in suggestions.txt
and submit by creating a pull request :)