GitHub / Git Familiarization

Forking and Creating a Pull Request

Fork this GitHub repository using the GitHub user interface.

Then, clone the repository on your machine. Use the appropriate URL from the GitHub UI (either HTTP or SSH, depending on your settings).

Edit the README.md file using your favorite editor, and add your name and GitHub ID to it.

Commit the changes locally.

git add README.md
git commit -m 'Add name for YOURNAME'

Push your changes to GitHub.

git push

Submit a pull request using the GitHub UI.

Note: your branch may go out of date before your submit a pull request. In this case, update your fork using the GitHub UI, update your local copy (git pull), push your updates back to GitHub (git push) and submit a pull request.

Once your pull request has been accepted you can delete the repository.

Branching

Clone the original repository directly.

git clone git@github.com:sree314/csc293-fall23 # if you use SSH urls
# or if you use HTTPS urls
# git clone https://github.com/sree314/csc293-fall23.git

Create a branch:

cd csc293-fall23
git checkout -b BRANCHNAME  # replace BRANCHNAME with a short name

Edit the README.md file to add your planned year of graduation after your name.

Commit and push the changes. (You should accept my invite to collaborate on the repository)

git add README.md
git commit -m 'Added YOURNAME graduation year'
git push

You should see a message telling you a URL you can click to open a Pull Request. Do it.

I will merge your requests in.

You can then delete your branch locally:

git checkout main # switch branch
git branch # shows you the branches you have
git branch -d BRANCHNAME # whatever name you chose

Merge Conflicts

Read the GitHub documentation on handling merge conflicts in Git.

Demonstration of handling merge conflicts.

Discussion

References

  1. GitHub Tutorial
  2. GitHub Cheatsheet (English PDF)