Git
Tak Po prostu

 


About Me

 

AgENDA

  • Basics
  • Branches
  • Remotes
  • Rebase
  • Bisect
 

SVN USerS see


PAdaWAN

 

Open console

   For pro
git init --bare bare-workshop
git init workshop

Create Git REpository

 

Adding

Add some file


We will use `fortune` to create content

 cd workshop
 fortune > first

 git add -p first
 git add first

for pro

Commit


 git commit

 

REvertING

Add some content to file

 fortune > first
Show that change
 cat first
or better lets use diff
 git diff
and revert it to commited state
 git checkout first


pro can try
 git checkout -p first


 

Knight

Branching

git have powerfull branching model

Branch

show branch in repo

 git branch

add branch
 git branch awesome-branch
delete branch (if it is merged)
 git branch -d awesome-branch
delete unmerged branchs
 git branch -D awesome-branch


Add Commit To branch

Create branch and checkout to it

 git branch new-branch
 git checkout new-branch 
or shortcut
 git checkout -b newer-branch
and add some commits


 

 at lease 4 with 2 commits

MAke MORE Branches

 

MERGING

MergING

 git checkout -b master
git merge [branch-name-here]
simple merge



resolve conflicts

 git mergetool

mergetool use external programs to perform merge

fastforward


Octopus MeRGE

OctoPUS MERGE

 git merge [first-branch] [second-branch] [thid-branch]

Cherry Pick

 git cherry-pick [commit-id]


Aliases

Some command in git could be very long

git log --graph --oneline --branches
It would be very nice to have command to do it
something like this
 git graph
It is possible
 git config alias.graph "log --graph --oneline --branches"
after this we can use
git graph 

More Aliases

We can run even programs from


 git config alias.sbt '!sbt'
! here means run it in shell
with working directory set repository root

Master

 

Each Git repository
IS EQuivalent

Lets Clone REMOTE rEPO

 git clone [my-ip-address]



It copy all data from remote repo to local
for Linux it take around ~6 GB
it can be omitted using shallow clone

It automatically creates remote called origin

Git FEtch

How to get new data in our repository ?

 git fetch origin
It can takes not only remotes but
  • HTTP
  • SSH
  • RSYNC
  • IP
  • other

Git PULL

It compilation  of


  1. fetch
  2. merge

GiT PUSH

Send changes to remote repository

git push [remote] [branch] 
push have nice switch --set-upstream

Full syntax
 git push [remote] [local-branch]:[remote-branch]

Detele remote branch
 git push [remote] :[remote-branch]

LoRD

REBase

Rebase USe

  • cleaning commit messages
  • reorder commit
  • rewriteing history

REBASE

 git rebase master feature

 

BiSECT

BiSECT

Used to find bug in large codebase (linux-kernel)

BiSECT

 git bisect start HEAD HEAD~99
git bisect run "./check"

Git tak po prostu

By bambucha

Git tak po prostu

  • 1,720