Beginners’
Git
with
6pm Wednesday�27th March 2024
UTS ProgSoc�Event #4
🏗️ Setting Up
git config --global core.editor code
📣 ProgSoc Announce
🤔 Why Git?
Git is a “version control” software, which keeps track of code changes and allows multiple people to easily work on the same codebase.
Usually there is a “main/master branch”, where team members branch off to do their work, and then merge their work back into the main/master branch.
Workshop Time!
🖼️ A Picture
Git keeps a sort of log book journal for your code.
It does this by keeping entries that track changes in your code, known as 'commits', inside a sort of database known as a 'repository'. Alongside each commit is a short description known as a 'commit message', and extra metadata such as the date, time and author.
These commits are made inside 'branches', which can peel away from the 'main' (or 'master') branch, or even other branches, to test new features, fixes or changes in a separate timeline.
📂 Folder Setup
🔰 Initialising Your Local Git Repository
Graphical
Command
Open the Git2024Local folder you created. Then:�Initialise Repository for VSCode, or git init in a terminal.
📄 Create Some Files
Graphical
Create README.md and guide.md, copying the contents from https://github.com/ProgSoc/Git2024
🕵️ Tracking Your First Files
Graphical
Once you’ve written to the files and saved them, stage the changes.
Command
🧾 Committing Your Changes
Graphical
Command
🦖 Checking History
Graphical
Command
🌿 Creating Your First Branch
Graphical
Command
✒️ Making a Change
Add this Git event, or your own idea for an event or project into guide.md
🤝 Merging Changes
Graphical
Command
Group Time!
🙂 Pick Your Groups
We’ve now got the hang of using Git locally,�but Git is also a collaborative tool!
Pick a group of 2+ people at your table,�and choose 1 to be repository ‘owner’.
Everyone should create GitHub accounts.�The owner will create a new empty repository�and add the other group members as ‘collaborators’.
>> How do I do all that? (Check the Next Slides)
🔑 Sign Up for GitHub 🔑
🍴 Forking the Workshop 🍴
📬️ Sharing Your Repository 📬️
🔐 Authenticating Git to GitHub
🧪 Cloning the Remote (Owner’s Fork)
Graphical
Command
git clone "https://github.com/<TeamOwner>/Git2024"
📮 Pushing Your Own Branch
Graphical
Command
🤔 What is a Pull Request?
When you are ready to merge your changes into the master (old name) or main (most repos use this now) branch of your repository, you must create a new pull request.
A pull request allows other members of your team to analyse and review the changes you are making to the code, being able to add comments and provide potential improvements.
It is best practice to have your pull request approved by at least one team member before merging the code back into master to mitigate any�issues with the code or incorrect changes in functionality.
📎 Making a Pull Request
or
��Because this is a fork, make sure you make the PR to your repo not to the ProgSoc one
🤝 Merging a Pull Request
To merge the changes, press “Merge pull request” and then confirm the merge.
There are multiple types of merges, being merging, squashing, and rebasing.
🤔 What is a Merge Conflict?
What happens if multiple people make a change to the same line?
You get a merge conflict!
Merge conflicts show what’s your current change, what’s the incoming change (what you’re trying to merge in), and you have to resolve them.
Resolving a Merge Conflict
The first step is to fix it in the code. For each conflict, press “Accept Current” or “Accept Incoming” and then make sure the code is right.
After the file’s conflicts are resolved, press the + on the file to stage it.
After all the conflicting files are staged, you can commit your merge!��(If you’re in a terminal, you can pick the change you think is right�between matching <<<<<<<, +======, and >>>>>>> in the files)
😕 Inducing a Merge Conflict
In order to create a merge conflict (for educational reasons), do the following:
🚀 Where to From Here?
Collaboration Time!
⚠️ Creating Issues ⚠️
If you’ve found something that needs fixing or have an idea,�but you don’t have the programmer skills yet to contribute:�Submit an issue to help keep track of it.
⭕️ Live Collaboration ❌�❌ Noughts & Crosses ⭕️
Copy in small, specific areas as features or fixes from the completed files�Then submit your changes via Pull Requests to the live branch on the ProgSoc repo
🍕 Pizza Time! 🍕
Workshop Survey
Event Timing
<Doing a Thing in Git/>
Graphical
Command