A Short History of Git
Version control or source control is an important part of application development.
It records every change made to files over time in case you need to revert to the previous file version.
The birth of the Git tools and the Github site came out of the need to keep track of code changes during the early days of linux development.
Linus Torvalds started development on this project in the early 1990’s. By switching to a GPL (General Public License) he was able to attract developers for this massive project and code would be free for use. Keeping track of all this code from various developers became unmanageable and a tool needed to handle this operation.
The first package to attempt to handle this massive task was called Bitkeeper. By 2002 it was clear that this package needed an overhaul and Git was created.
Linux became one of the largest software projects ever and consisted of millions of lines of code.
Some key concepts needed for a source code management system.
Traceability, software bugs can be identified.
A distributed Workflow so developers can have access to all the work on the project.
Needed to be fast and safe from corruption.
Linus Torvalds quote "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'." With Git being a British expression for a contemptible or silly person.
Linus Torvalds torvalds@linux-foundation.org
Reversibility: If you write code that breaks everything at 4:00 PM, you can instantly "rewind" the entire project back to how it looked at 9:00 AM.
Collaboration: It allows multiple people to work on the exact same files simultaneously without overwriting each other's work.
Accountability: It keeps a detailed log of who changed what, when, and why.
Experimentation: You can create a "Branch" (a sandbox copy) to try out a wild new feature. If it works, you merge it back; if it fails, you just delete the branch and the main project remains untouched.
Implementation and design of a Reliable, High-performance, Distributed, Content Manager
Performance and distributed nature
Security and trust issues
Commit changes without disturbing others
Trust your data
Not a single point of failure
What is Git?
Git is a distributed version-control system for tracking changes in code
during software development.
A GitHub repository is a storage space where your project's files are in one centralized location, allowing you to manage and share code with collaborators.
fast-version-control
What is GitHub?
GitHub is a platform for version control and collaboration. It uses concepts like repositories, branches, commits, and Pull Requests.
What is a Git repository?
A Git repository is the .git/ folder inside a project.
Tracks all changes made to project files .
You can create a git repository from your local files or you can pull down a hosted repository from the github site.
Initializing a Repository in an Existing Directory
Project directory and you want to start controlling it with Git,
To create a repository on your local system you should create a directory to hold your files.
john_iacovacci1@cloudshell:~ (cloud-project-examples)$ mkdir python-invoicer
john_iacovacci1@cloudshell:~ (cloud-project-examples)$ cd python-invoicer
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git init
Initialized empty Git repository in /home/john_iacovacci1/python-invoicer/.git/
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Git has 3 stages:
Untracked: file exists, not under git's version control.
Staged: file added to git control but changes not been committed.
Committed: the change has been committed.
Check the state of the working directory and the staging area.
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Create a README.md file
Markdown(.md) is a markup language with plain-text-formatting syntax,
# python-invoicer project
This is a sample README.md file
Python invoicer will produce an invoice on products sold
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Add README.md to in the working directory to the staging
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git add README.md
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: README.md
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Git commit is used to save your changes to the local repository
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git config --global user.email "john.iacovacci1@gmail.com"
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git config --global user.name "Google Cloud Developer"
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git commit -m "First file in python-invoicer repository"
[master (root-commit) fbb6be2] First file in python-invoicer repository
1 file changed, 3 insertions(+)
create mode 100644 README.md
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git status
On branch master
nothing to commit, working tree clean
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ ls -al
total 16
drwxrwxr-x 3 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:05 .
drwxr-xr-x 79 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:21 ..
drwxrwxr-x 8 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:25 .git
-rw-r--r-- 1 john_iacovacci1 john_iacovacci1 115 Feb 18 18:09 README.md
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Change into the .git directory to look at files (managed by git do not change)
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ cd .git
Review the created git structure
john_iacovacci1@cloudshell:~/python-invoicer/.git (cloud-project-examples)$ ls -al
total 52
drwxrwxr-x 8 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:25 .
drwxrwxr-x 3 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:05 ..
drwxrwxr-x 2 john_iacovacci1 john_iacovacci1 4096 Feb 18 17:54 branches
-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 41 Feb 18 18:23 COMMIT_EDITMSG
-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 67 Feb 18 17:54 config
-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 73 Feb 18 17:54 description
-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 23 Feb 18 17:54 HEAD
drwxrwxr-x 2 john_iacovacci1 john_iacovacci1 4096 Feb 18 17:54 hooks
-rw-rw-r-- 1 john_iacovacci1 john_iacovacci1 137 Feb 18 18:23 index
drwxrwxr-x 2 john_iacovacci1 john_iacovacci1 4096 Feb 18 17:54 info
drwxrwxr-x 3 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:23 logs
drwxrwxr-x 7 john_iacovacci1 john_iacovacci1 4096 Feb 18 18:23 objects
drwxrwxr-x 4 john_iacovacci1 john_iacovacci1 4096 Feb 18 17:54 refs
john_iacovacci1@cloudshell:~/python-invoicer/.git (cloud-project-examples)$
Check the repository using git log A Git log is a running record of commits.
john_iacovacci1@cloudshell:~/python-invoicer/.git (cloud-project-examples)$ cd ..
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git log
commit fbb6be239c112c9ac32a7fa5dcb16527d7d39ba3 (HEAD -> master)
Author: Google Cloud Developer <john.iacovacci1@gmail.com>
Date: Wed Feb 18 18:23:57 2026 +0000
First file in python-invoicer repository
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Now we can edit the README.md file by adding lines
Collects customer information
Display Inventory
Calculates Invoice based upon customer quantity
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
Create account on github.com
I used continue with Google
Create new repository
Create new repository called python-invoicer
Need to connect with github
Check for share ssh key with github
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ ls -al ~/.ssh
Generate key
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ ssh-keygen -t ed25519 -C "john.iacovacci1@gmail.com"
Wake up keychain manager
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ eval "$(ssh-agent -s)"
Hand key to manager
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ ssh-add ~/.ssh/id_ed25519
Make key visible to copy to github
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ cat ~/.ssh/id_ed25519.pub
Put ssh key in gitbub - Settings
Deploy keys
Paste key values
You can now connect to github
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git remote add origin https://github.com/jiacovacci/python-invoicer.git
Push committed code up to site
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git push -u origin main
README.md file now on github
Put the invoicer program form homework assignment in directory
Add files to repository
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git add invoicer.py
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git commit -m "Invoicer"
[main c11bb1c] Invoicer
2 files changed, 140 insertions(+)
create mode 100644 invoicer.py
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$ git push -u origin main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.12 KiB | 573.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:jiacovacci/python-invoicer.git
fbb6be2..c11bb1c main -> main
branch 'main' set up to track 'origin/main'.
john_iacovacci1@cloudshell:~/python-invoicer (cloud-project-examples)$
No comments:
Post a Comment