Git Advanced Workshop

Tibor Stanko

1 Intro

About me

  • Tibor Stanko, 34 years
  • since 2020 Data Engineer in Zurich Insurance, Bratislava πŸ‡ΈπŸ‡°
  • before that, 6 years in academia in πŸ‡«πŸ‡· (PhD, postdoc)
  • I enjoy automating boring tasks using Python 🐍
  • not a Git guru, but I’ve been using Git daily for over 10 years
  • my hobbies: πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦πŸš²β›°οΈπŸŽΈπŸŽΉπŸΊ

Contents of this workshop

2 Git internals

What lies inside Git?

What is Git?

  • version control system (VCS) or source control management (SCM)
  • in Slovak: systΓ©m riadenia verziΓ­
  • keeps track of project development history
  • useful for teams and for individuals
  • not only about code, enables saving arbitrary files (including non-text)

But… what really is Git?

  • Git is a content-addressable file system
  • This means that the address of a file (key) is defined by its content
  • At the core of the Git system is a simple data store that can be accessed using keys
  • Key = SHA-1 hash, e.g., 655a20f99af32926cbf6d8fab092506ddd70e49c

What does Git store?

Mainly:

  • objects
  • references (or refs)

Objects

  1. blob
    • only content, no metadata (path, name)
  2. tree
    • a tree contains blobs or other trees
  3. commit
    • contains pointers to a tree and another commit (parent)
  4. tag
    • defines an alternative name for another object, which can be used to interact with the object instead of the hash

Each object is identifiable by its SHA-1 hash.

References = pointers to objects

  • A branch is not a sequence of commits, but just a pointer to a specific commit
cat .git/refs/heads/main
# 7c66409021358486e63d2d40c9b07e2c35e8124d

cat .git/refs/remotes/origin/dev
# c29dc332ac3eebebffc5726e16d0e91df170103f

cat .git/refs/tags/v2.6.3
# d49de0ec577052db3e47e2baf5aff0be738637ac

Tip: In PowerShell, you can use gc (alias for Get-Content) instead of the cat command.

Types of Commands

Porcelain:

  • high-level commands used by everyday users
  • commit, log, merge, pull, push, status, …

Plumbing:

  • β€œcore git”
  • low-level commands used internally by Git (or by power users)
  • cat-file, commit-tree, hash-object, ls-files, merge-base, rev-parse, …

Demo

  • powershell
  • .git tree

cd ~
git init test
# Initialized empty Git repository in 
# C:/Users/tibor.stanko/test/.git/
cd test
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”‚
β”œβ”€β”€ objects
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── refs
    β”œβ”€β”€ heads
    |
    └── tags

echo "version 1" > test.txt
git status
# On branch main
# No commits yet
#
# Untracked files:
#         test.txt
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”‚
β”œβ”€β”€ objects
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── refs
    β”œβ”€β”€ heads
    |
    └── tags

git add test.txt
git status
# On branch main
# No commits yet
#
# Changes to be committed:
#         test.txt
git ls-files --stage
# 100644 594dc0e39bc4468ee19c
#        67e65d37b97eb963b68b 0 test.txt
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”œβ”€β”€ index
β”œβ”€β”€ objects
β”‚   └── 59 blob [test.txt] 'version 1'
β”‚       └── 4dc0e39bc4468ee19c67e65d37b97eb963b68b
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── refs
    β”œβ”€β”€ heads
    |
    └── tags

git commit -m "First"
# [main (root-commit) c771cdc] First
#  1 file changed, 0 insertions(+),
#   ... 0 deletions(-)
#  create mode 100644 test.txt
git status
# On branch main
# nothing to commit, working tree clean
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”œβ”€β”€ index
β”œβ”€β”€ objects
β”‚   β”œβ”€β”€ 59 blob [test.txt] 'version 1'
β”‚   β”‚   └── 4dc0e39bc4468ee19c67e65d37b97eb963b68b
β”‚   β”œβ”€β”€ 67 tree [blob 594d]
β”‚   β”‚   └── 4d4d31b97233152f3be1825cc9e765fa2b2859
β”‚   └── f8 commit [tree 674d] "First"
β”‚       └── 0a04ee3dfbeb5eb666ade615abc617c1ea20e3
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── refs
    β”œβ”€β”€ heads
    |   └── main f80a...
    └── tags

mkdir bak
mi test.txt bak
echo "version 2" > test.txt
git add .
git commit -m "Second"
# [main 4ba094f] Second
#  2 files changed, 0 insertions(+), 
#   ... 0 deletions(-)
#  create mode 100644 bak/test.txt
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”œβ”€β”€ index
β”œβ”€β”€ objects
β”‚   β”œβ”€β”€ 59 blob [test.txt] 'version 1'
β”‚   β”‚   └── 4dc0e39bc4468ee19c67e65d37b97eb963b68b
β”‚   β”œβ”€β”€ 67 tree [blob 594d]
β”‚   β”‚   └── 4d4d31b97233152f3be1825cc9e765fa2b2859
β”‚   β”œβ”€β”€ f8 commit [tree 674d] "First"
β”‚   β”‚   └── 0a04ee3dfbeb5eb666ade615abc617c1ea20e3
β”‚   β”œβ”€β”€ f0 blob [test.txt] 'version 2'
β”‚   β”‚   └── d983103c610431663d84b3012d1b172f2f52ea
β”‚   β”œβ”€β”€ 37 tree [tree 674d, blob f0d9]
β”‚   β”‚   └── 87931e43c8baf51f3ffafc44f6394651a505ca
β”‚   └── 53 commit [tree 3787, par. f80a] "Second"
β”‚       └── 9f7e662b0fa2ceb0df1dc9332179b06e5cdaec
β”‚
β”‚
β”‚
β”‚
β”‚
β”‚
└── refs
    β”œβ”€β”€ heads
    |   └── main 539f...
    └── tags

echo "new" > new.txt
git add new.txt
git commit -m "Third"
# [main 62e37a9] Third
#  1 file changed, 0 insertions(+), 
#   ... 0 deletions(-)
#  create mode 100644 new.txt
.git
β”œβ”€β”€ HEAD    ref: refs/heads/main
β”œβ”€β”€ index
β”œβ”€β”€ objects
β”‚   β”œβ”€β”€ 59 blob [test.txt] 'version 1'
β”‚   β”‚   └── 4dc0e39bc4468ee19c67e65d37b97eb963b68b
β”‚   β”œβ”€β”€ 67 tree [blob 594d]
β”‚   β”‚   └── 4d4d31b97233152f3be1825cc9e765fa2b2859
β”‚   β”œβ”€β”€ f8 commit [tree 674d] "First"
β”‚   β”‚   └── 0a04ee3dfbeb5eb666ade615abc617c1ea20e3
β”‚   β”œβ”€β”€ f0 blob [test.txt] 'version 2'
β”‚   β”‚   └── d983103c610431663d84b3012d1b172f2f52ea
β”‚   β”œβ”€β”€ 37 tree [tree 674d, blob f0d9]
β”‚   β”‚   └── 87931e43c8baf51f3ffafc44f6394651a505ca
β”‚   β”œβ”€β”€ 53 commit [tree 3787, par. f80a] "Second"
β”‚   β”‚   └── 9f7e662b0fa2ceb0df1dc9332179b06e5cdaec
β”‚   β”œβ”€β”€ dc blob [new.txt] 'new'
β”‚   β”‚   └── 334bff12fb7d7404c79935fa3ba535c3bb28d0
β”‚   β”œβ”€β”€ b0 tree [tree 674d, blob f0d9, blob dc33]
β”‚   β”‚   └── ea95a512bad604278bcc96e8b8e726b462e010
β”‚   └── 62 commit [tree b0ea, par. 539f] "Third"
β”‚       └── e37a96f8f09d0421644817dea320108ceac481
└── refs
    β”œβ”€β”€ heads
    |   └── main 62e3...
    └── tags

 

.git for a real project

pybrickz/.git
β”‚   COMMIT_EDITMSG  last commit message edited in the local repository
β”‚   config          local configuration, applies only to this repository
β”‚   description     don't worry about it
β”‚   FETCH_HEAD      remembers what was last fetched from the remote repository
β”‚   HEAD            pointer to the current branch/commit
β”‚   index           binary list of paths and SHA-1 hashes, view content with `git ls-files --stage`
β”‚   ORIG_HEAD       previous state of HEAD, set by commands with potentially dangerous behavior
β”‚   packed-refs     packed references (heads, tags)
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects […]
└───refs […]

.git/objects

pybrickz/.git
β”‚   […]
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects  objects - blobs, trees, commits
β”‚   β”œβ”€β”€β”€00
β”‚   β”‚       57f7cf16175d94fa850ad30918dffcd4cd850c
β”‚   β”œβ”€β”€β”€01
β”‚   β”‚       4daec1e8a05a71852209c4caf9750bfe4717b1
...
β”‚   β”œβ”€β”€β”€fe
β”‚   β”‚       1c754ef352dece245b5f7a0d7047b048d7b1d9
β”‚   β”‚       8a73f88812537678fde89e91c19c87623ff47c
β”‚   β”œβ”€β”€β”€ff
β”‚   β”‚       7e837bf1dc59b8835767fdcf789e308528498a
β”‚   β”œβ”€β”€β”€info […]
β”‚   └───pack […]
└───refs […]

.git/refs

pybrickz/.git
β”‚   […]
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects […]
└───refs     references - branches, remote branches, tags
    β”œβ”€β”€β”€heads […]
    β”œβ”€β”€β”€remotes […]
    └───tags […]

.git/refs/heads

pybrickz/.git
β”‚   […]
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects […]
└───refs
    β”œβ”€β”€β”€heads
    β”‚       dev
    β”‚       main
    β”‚       staging
    β”‚       β”œβ”€β”€β”€bugfix
    β”‚       β”‚       bugfix-1    branch created via `git branch bugfix/bugfix-1`
    β”‚       β”‚       bugfix-2    branch created via `git branch bugfix/bugfix-2`
    β”‚       └───feature
    β”‚               feature-A   branch created via `git branch feature/feature-A`
    β”‚               feature-B   branch created via `git branch feature/feature-B`
    β”œβ”€β”€β”€remotes […]
    └───tags […]

.git/refs/remotes

pybrickz/.git
β”‚   […]
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects […]
└───refs
    β”œβ”€β”€β”€heads […]
    β”œβ”€β”€β”€remotes
    β”‚   β”œβ”€β”€β”€gh
    β”‚   β”‚       main
    β”‚   └───origin
    β”‚       β”‚   dev
    β”‚       β”‚   HEAD
    β”‚       β”‚   main
    β”‚       β”œβ”€β”€β”€bugfix
    β”‚       β”‚       bugfix-2
    β”‚       └───feature
    β”‚               my-awesome-feature-A
    └───tags […]

.git/refs/tags

pybrickz/.git
β”‚   […]
β”œβ”€β”€β”€hooks […]
β”œβ”€β”€β”€info […]
β”œβ”€β”€β”€logs […]
β”œβ”€β”€β”€objects […]
└───refs
    β”œβ”€β”€β”€heads […]
    β”œβ”€β”€β”€remotes […]
    └───tags
            v1.0.0
            v1.0.1
            ...
            v2.6.4
            v2.7.0

.git/HEAD

  • HEAD is a pointer to the current branch or commit
  • DETACHED HEAD is a situation where HEAD points to a commit that is not the head of a branch
cat .git/HEAD
# ref: refs/heads/main
git checkout 7c66409
git status
# HEAD detached at 7c66409
# nothing to commit, working tree clean
cat .git/HEAD
# 7c66409021358486e63d2d40c9b07e2c35e8124d

Exercises (1)

  1. Clone the test repository:
git clone https://github.com/bbrrck/hello.git 
  1. From the .git directory, find the file with the hash that the slovak branch points to.
  2. Compare the hash with the output of the git rev-parse slovak command.
  3. Using the git cat-file -p command multiple times, find out what content is in the hello.py file on the slovak branch.
    • Hint: use the hash from the previous step as the argument for -p.

3 Merge vs. Rebase

Merging Changes

In Git, there are two main ways to integrate changes from one branch into another: merge and rebase.

Merging Changes

Merging via merge

  • the simplest way to combine branches
  • a three-way merge between two branches (e.g., main and feature) and their latest common ancestor
  • creates a new commit

Merging via merge

Merging via rebase

  • rebasing the feature branch onto the main branch means moving the start of the feature branch to the end of the main branch
  • this means that commits from feature will be recreated on the main branch
  • main advantage: a cleaner, more linear project history with fewer β€œforks”

Merging via rebase

When not to use rebase?

  • never use git rebase on public or collaborative branches (especially main)
  • otherwise, part of the history may be changed or even deleted

When not to use rebase?

Demo: merge

git clone https://github.com/bbrrck/hello.git hello-merge; cd hello-merge
git merge origin/french
# Auto-merging hello.py
git merge origin/slovak
# CONFLICT (content): Merge conflict in hello.py
# ... resolve the conflict ...
git add .
git commit
# [main cef4a72] Merge remote-tracking branch 'origin/slovak'

Demo: rebase (french)

git clone https://github.com/bbrrck/hello.git hello-rebase; cd hello-rebase
git checkout french
git rebase main
# Successfully rebased and updated refs/heads/french.
git checkout main
git merge french
# Updating 0297280..5f6f019
# Fast-forward
#  hello.py | 11 ++++++++++-
#  1 file changed, 10 insertions(+), 1 deletion(-)

Demo: rebase (slovak) - conflict

git checkout slovak
git rebase -i main
# ... mark the middle commit as `fixup` ...
# CONFLICT (content): Merge conflict in hello.py
# ... resolve the conflict ...
git add .
git rebase --continue
# Successfully rebased and updated refs/heads/slovak.
git checkout main
git merge slovak # Fast-forward

git log --oneline --graph --all

Merge:

*   cef4a72 (main) Merge branch 'slovak'
|\
| * 163a9c3 (slovak) Add docstring for slovak
| * bd67d8d Fix slovak
| * 75fcf88 Add slovak
* |   bc3f86b Merge branch 'french'
|\ \
| * | a31caf9 (french) Add docstring for french
| * | 6d348f3 Add french
| |/
* / 0297280 Add docstring for default
|/
* 4b4a8ad Add hello.py
* 60d4d94 Initial commit

Rebase:

* ab2fda1 (main, slovak) Add docstring for slovak
* 806b97a Add slovak
* 5f6f019 (french) Add docstring for french
* ea40a3b Add french
* 0297280 Add docstring for default
| * 163a9c3 Add docstring for slovak
| * bd67d8d Fix slovak
| * 75fcf88 Add slovak
|/
| * a31caf9 Add docstring for french
| * 6d348f3 Add french
|/
* 4b4a8ad Add hello.py
* 60d4d94 Initial commit

git log main --oneline

Merge (10):

cef4a72 (main) Merge branch 'slovak'
bc3f86b Merge branch 'french'
0297280 Add docstring for default
163a9c3 (slovak) Add docstring for slovak
bd67d8d Fix slovak
75fcf88 Add slovak
a31caf9 (french) Add docstring for french
6d348f3 Add french
4b4a8ad Add hello.py
60d4d94 Initial commit

Rebase (7):

ab2fda1 (main, slovak) Add docstring for slovak
806b97a Add slovak
5f6f019 (french) Add docstring for french
ea40a3b Add french
0297280 Add docstring for default
4b4a8ad Add hello.py
60d4d94 Initial commit

Exercises (2)

  1. Clone two copies of the test repository:
git clone https://github.com/bbrrck/zoo.git zoo-merge
git clone https://github.com/bbrrck/zoo.git zoo-rebase
  1. In the zoo-merge repository:
    1. Merge the origin/krokodil and origin/gorila branches into the local main branch using the git merge command.
    2. Resolve any conflicts that arise in both cases.

(continued on the next slide)

Exercises (2)

  1. In the zoo-rebase repository:
    1. Switch to the gorila branch and rebase it onto the main branch using git rebase. Resolve any conflicts that arise.
    2. Switch to the main branch and git merge the gorila branch into it.
    3. Switch to the krokodil branch and rebase if onto the main branch using git rebase -i. Mark the middle commit as fixup. Resolve conflicts.
    4. Switch to the main branch and git merge the krokodil branch into it.
  2. Use the git log command to compare the state of both repositories.
  3. What would change in the result if you skipped step 3b?

4 Frequent questions and issues

git revert

git revert HEAD   # remove changes made in the last commit
git revert HEAD~1 # remove changes made in the second to last commit
git revert d49de0 # remove changes made in the commit with hash d49de0

git revert creates a new version and does not change the repository history.

git reset

# revert the repository to the state *after* the commit with hash d49de0
git reset --hard d49de0

git reset --hard changes the repository history and can cause file loss.

reset vs revert vs checkout

Command Context Usage
git reset Commit Discard commits in a private branch or discard uncommitted changes
git reset File Remove a file from the staging area (from the index)
git checkout Commit Switch between branches or view old versions
git checkout File Discard changes in the working directory
git revert Commit Revert commits in a public branch
git revert File (N/A)

How do I revert local changes?

git commit -m "Something terribly misguided"
git reset HEAD~1
# ... modify files as needed ...
git add .
git commit -c ORIG_HEAD # open the previous message in the commit editor
git commit -C ORIG_HEAD # use the previous message without opening the commit editor

How do I revert changes that have already been pushed?

git commit -m "Something terribly misguided"
git push origin main
git reset HEAD~1
# ... modify files as needed ...
git add .
git commit -C ORIG_HEAD # use the previous message without opening the commit editor
git push origin main --force-with-lease # do not use '--force'!

How do I revert part of a commit?

git revert --no-commit $bad_commit  # revert the commit, but do not save changes
git reset HEAD .                    # unstage the changes
git add --patch .                   # stage the changes that should be *reverted*
git commit                          # create a commit to revert those changes
git checkout -- .                   # discard changes that should not be reverted

Note: The changes we add using the git add --patch command are the changes we want to revert, not the changes we want to keep.

How do I rename a local branch?

# rename the current branch to 'newname'
git branch -m newname

# rename the branch 'oldname' to 'newname'
git branch -m oldname newname

How do I delete a local and remote branch?

git push -d <remote_name> <branch_name>
git branch -d <branch_name>
git fetch --all --prune # remove references to deleted remote branches

How do I move the last n commits to a new branch?

Moving the last 3 commits from main to a new branch feature:

git checkout main           # switch to main
git branch feature          # create a new branch feature pointing to the same
                            # commit as main, but do not switch to it
git reset --hard HEAD~3     # remove the last 3 commits
git checkout feature        # switch to the feature branch

How do I unstage files from the staging area?

git restore --staged <file>

How do I change the message of an already created commit?

git commit --amend -m "New commit message"

If the old commit has already been pushed to the remote, after using git commit --amend you need to push with git push --force or --force-with-lease.

How do I add files to an already created commit?

git add forgotten_file
git commit --amend --no-edit # reuse the previous commit message

If the old commit has already been pushed to the remote, after using git commit --amend you need to push with git push --force or --force-with-lease.

How can I reset or revert a file to a specific version?

git checkout c5f567 -- file1/to/restore file2/to/restore

5 Git Workflows = Branching Models

In Git, there are many different workflows that differ in how they use branching. In this chapter, we will show some of the most commonly used workflows and their advantages and disadvantages.

What workflows exist?

  • Centralized
  • Feature branch (FB)
  • Trunk-based development (TBD)
  • Gitflow
  • Forking workflow
  • etc.

Centralized workflow

  • all developers work on one branch (main), no other branches are used

Advantages:

  • simple to understand, implement, and use
  • perfectly linear history

Disadvantages:

  • conflict resolution can be complex
  • does not utilize the potential of a distributed system

Feature branching

  • development takes place on separate feature branches, which are then merged into the main branch

Advantages:

  • new features are developed in isolation, stable main
  • allows the use of pull requests, code reviews, collaborative development

Disadvantages:

  • potentially many branches
  • resolving conflicts in long-lived branches can be complex

Trunk-based development

  • similar to the feature branching workflow, but feature branches are short-lived and frequently merged into the main branch (even several times a day)
  • suitable in combination with automated testing and deployment (CI/CD)

Advantages:

  • code on the main branch is always release ready

Disadvantages:

  • requires automated testing and deployment
  • requires a mature development team

Trunk-based development

Feature-based deployment can be beneficial for teams that value the isolation of features and are willing to manage the complexities of merging these features back into the mainline. On the other hand, trunk-based deployment is suited for organizations that prioritize rapid integration and releases and have the infrastructure to manage continuous integrations and feature flags.

In recent years, with the rise of DevOps and agile methodologies, there’s been a clear trend towards more frequent integrations and releases. This trend has made trunk-based development, with its emphasis on rapid integration and release, increasingly popular among many tech giants and startups alike. However, as with all methodologies, it’s essential to evaluate the specific needs and capabilities of an organization before adopting a deployment strategy.

Shared branches outside the mainline cause problems (merge hell)

Smaller teams

Larger teams

Gitflow workflow

  • extension of the feature branching workflow with develop, release, and hotfix branches
  • the purpose of each branch is clearly defined
    • main - production branch
    • develop - development branch
    • feature - development of new features
    • release - preparation for release
    • hotfix - fixing bugs in the production version

Gitflow workflow

Advantages:

  • all the advantages of the feature branching workflow
  • suitable for projects with longer development and regular releases

Disadvantages:

  • a large number of branches
  • merge hell

Gitflow is a legacy Git workflow that was originally a disruptive and novel strategy for managing Git branches. Gitflow has fallen in popularity in favor of trunk-based workflows, which are now considered best practices for modern continuous software development and DevOps practices. Gitflow also can be challenging to use with CI/CD.

Gitflow workflow

The overall flow of Gitflow is:

  1. A develop branch is created from main
  2. A release branch is created from develop
  3. Feature branches are created from develop
  4. When a feature is complete it is merged into the develop branch
  5. When the release branch is done it is merged into develop and main
  6. If an issue in main is detected a hotfix branch is created from main
  7. Once the hotfix is complete it is merged to both develop and main

Forking workflow

  • developers do not have direct access to the main repository but create a fork (copy) of the repository they work on
  • commonly used in open-source projects

6 Pull Requests

What is a pull request?

  • by creating it, we request the project maintainer to pull our changes and incorporate them into the project
  • it can be created within workflows such as feature or forking, but not within the centralized workflow
  • it allows developers to discuss the change and perform code reviews

Examples:

7 SSH Authentication

Creating an SSH key

ssh-keygen # use default settings
ssh-keygen -t rsa -C "[email protected]" # compatible with most git providers
ssh-keygen -t ed25519 -C "[email protected]" # compatible with GitHub

Copying the SSH key to the clipboard

Powershell

Get-Content ~\.ssh\id_ed25519.pub | Set-Clipboard

 

Command Prompt

clip < ~\.ssh\id_ed25519.pub

8 What We Didn’t Learn

  • hooks
  • submodules
  • pruning
  • cherry picking
  • LFS = Large File Storage
  • garbage collection (git gc)

Git Glossary

en sk
branch vetva
clone naklonovanie repozitΓ‘ra
commit zΓ‘znam
commit message popis zΓ‘znamu
conflict konflikt medzi verziami
conflict resolution rieΕ‘enie konfliktov
diff rozdiel medzi verziami
merge zlúčenie vetiev
en sk
pull stiahnutie vzdialenΓ½ch zmien
push odoslanie lokΓ‘lnych zmien
repository repozitΓ‘r, ΓΊloΕΎisko
remote vzdialenΓ½ repozitΓ‘r
snapshot snΓ­mka
staging area prΓ­pravnΓ‘ oblasΕ₯ (tieΕΎ index)
status stav repozitΓ‘ra
version verzia

Git Cheatsheet

# Setup
git config --global user.name "[first last]"
git config --global user.email "[valid-email]"
git init
git clone [url]
# Stage & Snapshot
git status
git add [file]
git reset [file]
git diff
git diff --staged
git commit -m "[descriptive message]"
# Branch & Merge
git branch
git branch [branch-name]
git checkout
git merge [branch]
git log
# Share & Update
git remote add [alias] [url]
git fetch [alias]
git merge [alias]/[branch]
git push [alias]/[branch]
git pull

Thanks for your attention! πŸ‘‹