Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Git basics a starter on git and its ecosystem
1. GIT BASICS
How to quickly use Git for day to day developments
...
AND STASH
Leverage Git on the Enterprise
Created by /
Original presentation on
François D'Agostini @DagoFrancesco
GitHub
2. WHAT IS GIT ?
DISTRIBUTED VERSION CONTROL
Speed
Simple
Non Linear Development
Fully Distributed
Large Projects
5. CREATION OF A REPO
No need for network
Can do a lot locally on PC
Best for testing
Git init: repo + working directory
git init --bare: Repo only
git clone:From an existing repo
9. VIEWING COMMITS HISTORY
...lots of other options !!
git blame: one files only
gitk: for graphic visualization
same options as git log
gitlog
--decorate
--graph
--stat
--oneline
-n
10. COMMITS HISTORY (2)
git show: details about a commit by default, shows the detail
of the most recent commit
git show-branch: show details about the current branch
HANDY ALIAS
gitconfig--globalalias.graph"log--decorate--graph--oneline"
11. VIEWING COMMIT DIFFERENCES
git diff: differences between the working directory and the
index
--cached: between the index and the most recent commit
HEAD: between the working directory and the most recent
commit
12. CANCELLATION, RESTORATION, CLEANING
git reset: cancels changes about to be commited in the
index
--hard: changes also the working directory
git checkout: cancels changes made to working directory
compared to index
git clean: deletes files not followed by Git.
-f option to really delete them
-n to simulate
.gitignore file: to avoid Git to track useless files
13. BRANCH MANAGEMENT
A Branch is just a pointer to a commit
nothing fancy
very lightweight
very similar to "tags"
stored in .git/refs/[heads|remotes|tags]
Default branch name: master
14. BRANCH MANAGEMENT (2)
git branch: list branches
-r: remote branches as well
-a all branches
git branch dev: create branch "dev"
Does not change the current branch
git checkout dev: move the current branch to the "dev"
branch
-b: create the branch while switching to it
15. MERGING
git merge dev:merges "dev" branch into current branch
does not destroy "dev"
git branch -d dev:deletes the "dev" branch
only deletes the pointer
can be deleted only if the branch is accessible from the
current branch
This is usually what is needed after merging. The old
"dev" pointer is no longer useful
in case of future branching, a new branch can be
created
16. CONFLICT RESOLUTION
git merge can lead to conflicts if the same file has been
modified in two branches
manual conflict resolution is needed on this files
conflict markers are added by git and need to be removed
by the developper
git add on the conflict files
git commit to end the merge
and of course, delete the merged branch
if conflict resolution is too complex:
git merge --abort: restores the working directory to the
state it was prior to merge
17. REMOTE REPOSITORIES
git remote: lists all remote repos linked to the current
local repo
git remote add name url: adds the specified url as a
remote repo to the local repo
No need in case repo has been created with git clone
git push repo: push local commits on the current branch to
the same branch on the remote repo
warning: the remote repo must already have the same
branch, else use git push repo branch
18. REMOTES: FETCHING AND PULLING
There is a separate copy of the remote commits separated
from the local branch
Can be seen using git branch -a
this means that the remote and the local copy can easily
be compared
git fetch repo: updates the local copy of the remote repo
git pull: like git fetch, but also merges the remote commit
into this repo's branch
this one can lead to conflicts
19. GIT REBASE
When fetching commits from remote repos, there are two
ways to merge them:
regular merge: it will create a new commit every time
rebase: it will not create a new commit
allows to change the commits that were not published to
have new parents
very handy when you need to integrate other people
changes but continu your work
use: git rebase branch
git pull --rebase: will use the reboase algorithm in case of
conflicts instead of merge
20. STASH: SAVE YOUR WORK WHILE SWITCHING
CONTEXT
Allows to save your current context and switch work
Then, you can restore the exact state back
git stash save messages: stores the working director and
the index into a stack
git stash list: lists all the saved stacks
git stash show: shows the details of a stack item
git stash pop: pops a state and applies it on the current
working directory
git stash drop: removes an item on the stack
21. STASH (2)
warning, stashing does not store the branch state
This means that you can recover your state on any branch
popping a state can create conflicts that needs to be
merged
if a pop failed because of a conflict, it will need to be
removed manually
22. GIT HOSTING IN THE
COMPANY
Different from git stash seen previously !!
STASH
23. WHY NEED A GIT HOSTING TOOL?
Git alone is not sufficient
To improve knowledge sharing
to improve code visibility
to get the code out of the darkness !!
25. PROJECT STRUCTURES
Stash organized by projects that handles multiple repos
permissions are based on projects and repos. Allows for
decentralized admin
users have roles: project creators, admins, system admins,
writer
Soon, anonymous mode
26. FILE BROWSING
Can browser any file and see source code
Allows to change branches and tags
Can have details of each commit
browse list of commits and log
markdown support to explain source code organization
27. PULL REQUESTS
Implements best practices with respect to code review
Allows anyone to create a branch, make some code and
ask for its merge
Branch permissions allows to control commits
Pull requests allow to review, make comments, ammend
new commits, see diffs...
Anyone can watch a pull request and be notified
Pull requests can be declined or accepted
28. FORKING
fork a repo into another repo, but keep history
allows for later merges
30. JIRA LINK
Allows to link Git commit to Jira issues
from a Jira issue, see all related commits
with Git hooks, you can force it
31. BRANCHING STRATEGIES WITH GIT
Git is small tool that does not come with a whole
environment and rules (think Clearcase...)
Git is versatile and can be used in a dozen of different
ways
Git itself does not enforce how to use branches and how
to work as a team. It keeps this open
But how a serious company is supposed to use git for all its
projects without going messy ?
WENEED BEST PRACTICES !!
32. GIT FLOW
Standard usages of branches when working with Git
Used in Big projects, with many developers working on it
33. MAIN CARACTERISTICS
2 long lived branches : Develop and master
3 short lived branches: Feature, Release and HotFix
The master branch is restricted to commit by one or two
people
The Develop branch is restricted to senior developers
New code is added through Feature branches only
34. STEPS TO FOLLOW
Create a Feature branch, name it to the story/feature you
are working on
once you are happy with your features, you create a pull
request to merge it
35. STEPS TO FOLLOW (2)
When a release must be done, use a temporary release
branch
The Master branch is used only for "stable" version
commits. Any commits on master should have a Tag
If a bug is found on Master, a "HotFix branch is created to
correct it and merge it back on master