Professional Documents
Culture Documents
Git MW Ensit
Git MW Ensit
Definition
Types
Advantages Disadvantages
Easy to learn and manage. Needs to connect to the network to
perform operations.
More control over users and their access. Risk of losing all data if the central server
gets crashes.
Can’t collaborate at all when the central
server is down.
For every command, CVCS connects the
central server which impacts speed of
operation
>VCS
Types
Advantages Disadvantages
Can work offline, unless we need to use Initial checkout of a repository is slow.
central repository for push and pull.
Faster than CVCS & Better performance.
Merging and branching is easy
(sometime there is no need to do it
manually).
Code is safe even the central server is
crashed.
Today‘s Lesson Agenda
Definition
DVCS
> G I T
Features
Branching is easier
Extensible
Tracks history
> G I T
Workflow
Workflow
We can divide the Git Workflow into 4 states:
§ Working Directory: The workspace where we
update/create/delete our files.
§ Staging Area (Index): Intermediate place between the
working directory and local repo. It’s used to stage
which files we want to track & commit.
§ Local repository: the local version of the repository. All
the commits come here first.
§ Remote repository: Remote server which hosts our
repository and to/from which we push/pull our
changes.
Commit Branch
commit is recording changes of Branch is similar to “parallel
set of files. In this operation, we universe” so it basically creating a
> G I T create a snapshot for the current new line of development which we
state of the project. usually create when we want to
For each commit we have: work on a new feature and
Key words Snapshot. merged it back with the master
Unique Identifier. branch which is by default the
Commit message. main.
Author and Timestamp.
Pull Push
Pull is the operation of copying all Push is the opposite operation of
the changes from a remote pull so it is copying all the
repository instance on our central changes from our local repository
server to a local one. to the remote one.
>GIT
Commands
Commands
Commands
Reverting Bonus
Ø git reset: Resets the repository to a Ø git it config --global
previous commit, removing all the alias.<shortcut> <command>:
commits and the changes after it. Creates our own aliases for
Ø git revert: Creates a new commit commands.
that undoes the changes from Ø git stash: Stores our changes
reverted commit. temporarily to avoid committing
them.
Ø git commit --amend -m "New
commit message": Changes the
last commit message.
Ø git commit --amend: Include
staged changes to the previous
commit.
>Git
Rebase vs Merge
Aspect Merge Rebase
History Preserves the original Adjust the history to
commit history. adapt to linear history.
Resulting One commit at the end Move all commits after
commits that have 2 parents. last commit of other
branch.
Conflicts Solve them once. Solve them with each
commit.
When to • Preserving Branch • Maintain a clean
use History. History.
• Shared Branch. • Solo Dev.
• Less Conflict • Feature Branch
Resolution. cleanup ( Re-order or
squash)
• Integration testing.
>Git
Best Practices
Task 1:
• Create directory
Task 2:
Task 3:
Task 4:
Task 5: