Skip to content

codersforcauses/lets-git-started-template

Repository files navigation

git-tute

Please ensure that you have git installed by running:

git --version

Git installation

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

Git Setup

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 johndoe@example.com

Exercise Setup

  1. Open Terminal / Power Shell and change directory into where you would like to store project and run:
git clone https://github.com/codersforcauses/lets-git-started.git
  1. Create a python virtual environment by running:
python3 -m venv venv
  1. Activate your virtual environment by running:

    If you have trouble activating your virtual environment, please skip to step 4.

For mac / linux

source venv/bin/activate

For windows

Powershell

venv/Scripts/Activate.ps1

Cmd

venv/Scripts/activate.bat
  1. Install the required packages by running:
pip install -r requirements.txt
  1. Install pre-commit by running:

This package will run a series of checks on your code before you commit it to ensure that your code is working as intended.

pre-commit install

Exercise

  1. For the excercise, create a copy of the template folder and rename it to the name of your group. Run:

cp -r ./template/ ./<your name>

For this exercise, there are 4 files that require completion


test_addition.py
test_subtraction.py
test_multiplication.py
test_division.py

Lets start by correcting test_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 test_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 so they can be viewed by our team mates. Push your changes by running:

git push

Work with your team to complete the other TODOs. For the purpose of this activity, please only modify 1 file per commit. Remember to push your changes and pull in changes made by your team.


Software Engineering Practices (Optional)

Please nominate one person from your group to do steps 2-5

  1. Create a new branch for your group by running (please create branch with the same name as your group):
git branch <name of branch>
  1. 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!

  1. to change to the branch created, Run:
git checkout <name of your branch>
  1. 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>

Adding changes to the main code base

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.

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.


Suggestions and feed back

Please leave any suggestions for future events or feedback in suggestions.txt and submit by creating a pull request :)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages