Intro to git git push -f origin main 2026-03-09 Prabuddha Hans Brendan Golden Git 2 / 107 Git • Git is tool that's used in the programming industry. 3 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. 4 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. • Specifically to track project work done, and the changes to files we've made. 5 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. • Specifically to track project work done, and the changes to files we've made. • The more correct term is Source Control. 6 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. • Specifically to track project work done, and the changes to files we've made. • The more correct term is Source Control. • It is NOT a programming language. 7 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. • Specifically to track project work done, and the changes to files we've made. • The more correct term is Source Control. • It is NOT a programming language. • Git is a tool made for (usually) us programmers to track the work we've done. 8 / 107 Git • Git is tool that's used in the programming industry. • Another name for Git is a Version Control System (VCS) tool. • Specifically to track project work done, and the changes to files we've made. • The more correct term is Source Control. • It is NOT a programming language. • Git is a tool made for (usually) us programmers to track the work we've done. 9 / 107 Sold Separately Programmer socks (not) included. 10 / 107 Why Git 11 / 107 Why Git • Now we need to ask WHY. 12 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? 13 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? 14 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? 15 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . 16 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . 17 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files 18 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files 19 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
20 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
◦ There are tools to prove a person wrote teh code 21 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
◦ There are tools to prove a person wrote teh code • What changes they committed
22 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
◦ There are tools to prove a person wrote teh code • What changes they committed
• Why they committed
23 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
◦ There are tools to prove a person wrote teh code • What changes they committed
• Why they committed
• When they committed
24 / 107 Why Git • Now we need to ask WHY. • Why would we need a tool like this? • Why not use Google Drive instead? • Why invest time into learning how to use it? . • Git tracks changes in (text) files ◦ There is an addon to handle non-text files • Who committed the code
◦ There are tools to prove a person wrote teh code • What changes they committed
• Why they committed
• When they committed
25 / 107 Code Storage 26 / 107 Code Storage • This place is called a Repository. 27 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. 28 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. 29 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. • Meaning that if a project breaks, you can go back to before it broke. 30 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. • Meaning that if a project breaks, you can go back to before it broke. • Now I hear you nerds in the audience asking... 31 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. • Meaning that if a project breaks, you can go back to before it broke. • Now I hear you nerds in the audience asking... • Why not use SVN? 32 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. • Meaning that if a project breaks, you can go back to before it broke. • Now I hear you nerds in the audience asking... • Why not use SVN? • The answer is simple. 33 / 107 Code Storage • This place is called a Repository. • Repositories are hosted on websites like GitLab, GitHub and Forgejo. • But, an interesting feature of git, is that it allows you to time-travel. • Meaning that if a project breaks, you can go back to before it broke. • Now I hear you nerds in the audience asking... • Why not use SVN? • The answer is simple. 34 / 107 No. 35 / 107 WHY don't we use SVN 36 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. 37 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. 38 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. 39 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. 40 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. • You can work locally on git without having to be connected, 41 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. • You can work locally on git without having to be connected, • and then push once you're reconnected. 42 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. • You can work locally on git without having to be connected, • and then push once you're reconnected. • Back to git. 43 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. • You can work locally on git without having to be connected, • and then push once you're reconnected. • Back to git. • Let's start with the basics. 44 / 107 WHY don't we use SVN • An actual answer is that Git is Distributed, and SVN in centralized. • Simply put, devs can store their changes locally on their machines. • Whereas on SVN they're stored on a central system. • With a central system you NEED to be connected at all times to work on it. • You can work locally on git without having to be connected, • and then push once you're reconnected. • Back to git. • Let's start with the basics. 45 / 107 Don't do these types of commit messages 46 / 107 Live demonstration time • Please get your laptops out 47 / 107 How to download Git https://git-scm.com/downloads 48 / 107 How to download Git 49 / 107 How to download Git For the default editor change it to Notepad or Notepad++. (if it is installed) 50 / 107 How to download Git Change the name of the default branch to main.
51 / 107 How to download Git We commit Unix style to avoid issues when running code on linux servers.
52 / 107 How to download Git 53 / 107 LFS 54 / 107 LFS • Git is very good for text files 55 / 107 LFS • Git is very good for text files • It is not good with Binary files 56 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries 57 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images 58 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs 59 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music 60 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music • For that we use LFS 61 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music • For that we use LFS • Large File Storage 62 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music • For that we use LFS • Large File Storage • It saves the files separately 63 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music • For that we use LFS • Large File Storage • It saves the files separately • Then uses a pointer/link to them 64 / 107 LFS • Git is very good for text files • It is not good with Binary files ◦ Binaries ◦ Images ◦ Word Docs ◦ Music • For that we use LFS • Large File Storage • It saves the files separately • Then uses a pointer/link to them 65 / 107 LFS Install https://git-lfs.com/ Same deal as before, just download and install. It'll ask to be ran as Administrator, say yes. 66 / 107 Basic Commands - init
▓▓▓ Info init is used to create a new repo in the same folder the command is run
▓▓▓ Command # create a new repo using the defaults
git init
# create a new repo with "trunk" as the default branch
git init -b trunk
# get teh full argument list/documentation
git init --help
67 / 107 Basic Commands - remote add
▓▓▓ Info Remotes are remote copies of the repo, hence the name "remote". This can be on Github/Gitlab/Forgejo or any other git webhost. <URL> is given to you when you create a web version of the repo.
▓▓▓ Command # Add a new remote called origin
git remote add origin <URL>
# Add a new remote called private
git remote add private <URL>
# Further documentation
git remote add --help
68 / 107 Basic Commands - add
▓▓▓ Info To be able to commit items they must be added to a staging area. ▓▓▓ Command # add a specific file to teh staging area
git add relative/path/to.file
# add all files named "file" to the staging area
# Extension does not matter
git add file.*
# Add all files that end in .txt to the staging area
git add *.txt
# Add everything
git add -A
# Further documentation
git add --help
69 / 107
Basic Commands - commit
▓▓▓ Info We commit all changes that are in the staging area in one go ▓▓▓ Command ▓▓▓ Example: Sign + GPG Sign
# Commit all the changes
git commit -m "message"
# Sign the message
git commit -s -m "message"
# GPG sign commit
git commit -S -m "message"
# Both sign off and GPG sign
git commit -s -S -m "message"
# Further documentation
git commit --help
70 / 107 Basic Commands - pull
▓▓▓ Info Always pull before using push
▓▓▓ Command # Get changes from the main branch of origin
git pull origin main
# Further documentation
git pull --help
71 / 107 Basic Commands - push
▓▓▓ Info Always pull before using push
▓▓▓ Command # Get changes from the main branch of origin
git push origin main
# Forcibly update the remote to yer changes
# WARNING: this could make ye loose data if not careful
git push origin main --force
# Further documentation
git push --help
72 / 107 Basic Commands - checkout
▓▓▓ Info Branches are a way of working on items in parallel. Can you find the other branches in this repo? ▓▓▓ Command # Checkout an existing branch
git checkout <branch>
# Create a new branch off of the current one
git checkout -b <new-branch>
# Checkout a specific commit (time travel back to then)
git checkout <commit>
# Further documentation
git checkout --help
73 / 107 Git && CI/CD - What 74 / 107 Git && CI/CD - What • Git is 20 years old. 75 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. 76 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD 77 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD • Continuous Integration/Continuous Deployment 78 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD • Continuous Integration/Continuous Deployment • This is where when code is pushed to a repo, pipelines run 79 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD • Continuous Integration/Continuous Deployment • This is where when code is pushed to a repo, pipelines run • These compile, test and deploy the code 80 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD • Continuous Integration/Continuous Deployment • This is where when code is pushed to a repo, pipelines run • These compile, test and deploy the code • Automation FTW! 81 / 107 Git && CI/CD - What • Git is 20 years old. • Because of this it ahs been incorporated in to general workflows. • Most notably CI/CD • Continuous Integration/Continuous Deployment • This is where when code is pushed to a repo, pipelines run • These compile, test and deploy the code • Automation FTW! 82 / 107 Git && CI/CD - Why 83 / 107 Git && CI/CD - Why • Humans are idiots 84 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts 85 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too 86 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too • Dont argue, this is just facts 87 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too • Dont argue, this is just facts • But they are really good at doing teh same task 88 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too • Dont argue, this is just facts • But they are really good at doing teh same task ◦ Again and Again and Again and Again.... 89 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too • Dont argue, this is just facts • But they are really good at doing teh same task ◦ Again and Again and Again and Again.... • So get them to handle the repetitive process of testing and deploying 90 / 107 Git && CI/CD - Why • Humans are idiots • Dont argue, this is just facts • Computers are idiots too • Dont argue, this is just facts • But they are really good at doing teh same task ◦ Again and Again and Again and Again.... • So get them to handle the repetitive process of testing and deploying 91 / 107 Git && CI/CD - Doing 92 / 107 Git && CI/CD - Doing • So with that in mind we are going to deploy a website to Skynet 93 / 107 Git && CI/CD - Doing • So with that in mind we are going to deploy a website to Skynet • Using git 94 / 107 Git && CI/CD - Doing • So with that in mind we are going to deploy a website to Skynet • Using git • And CICD 95 / 107 Git && CI/CD - Doing • So with that in mind we are going to deploy a website to Skynet • Using git • And CICD 96 / 107 Git && CI/CD - Doing https://forgejo.skynet.ie/Skynet/deploy_user 97 / 107 Git && CI/CD - Doing 98 / 107 Git && CI/CD - Doing 99 / 107 Setup SSH key (see Readme.md) Not a core part of this tutorial but instructions can be found here: https://forgejo.skynet.ie/Skynet/deploy_user/src/branch/main/README.md#create-ssh-ke y 100 / 107 Add SSH Key as a Secret Now we need to add the secret to Forgejo so it can pass it into teh CI/CD runner. Go up to Settings 101 / 107 Add SSH Key as a Secret Then Secrets 102 / 107 Add SSH Key as a Secret Add a Secret 103 / 107 Add SSH Key as a Secret If you followed the tutorial in teh README.md then ye can use. cat ~/.ssh/skynet/$USERNAME
Elsewise ye can use cat ~/.ssh/id_ed25519
Name the secret SSH_KEY
And paste in the value ye got from teh cat above exactly, keep the "armor".
104 / 107 Setup Local repo git init -b main
git remote add origin <repo_url>
git pull origin main
git checkout -b main
# Edit src/index.html
git add src/index.html
git commit -m "my first commit"
git push origin main
Then go to: https://<username>.users.skynet.ie/ 105 / 107 View live Site https://<username>.users.skynet.ie/ 106 / 107 TroubleShooting ▓▓▓ If you see this: ▍ Credit: Geeks for Geeks
▓▓▓ Go here https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a -new-ssh-key-and-adding-it-to-the-ssh-agent 107 / 107