CraftCamp for Students - Introduction to git

43
Introduction to Git Feedback: #craftcamps

Transcript of CraftCamp for Students - Introduction to git

Introduction to Git

Feedback: #craftcamps

Version Control● Samenwerken op 1 project

● Teruggaan naar vorige versie

● Aanpassingen vergelijken

● Commit history

Centralized Version Control

ClearCase, CVS, Perforce, Subversion...

Distributed Version Control

Bazaar, Git, Mercurial...

● Door Linus Torvalds in 2005

● Alternatief voor Bitkeeper

● Volledig file-based

● Huidige version: 2.4.5

git config --listgit config --global --list

Bekijk settings

git config --global user.name “Andy Van Den Heuvel”git config --global user.email “[email protected]

Stel gebruikersinfo in

git config --global http.proxy “http://proxy.server.com:8080”git config --global https.proxy “https://proxy.server.com:8080”

Stel proxy in

git config --global --unset http.proxy git config --global --unset https.proxy

Verwijder Config

Ready?

mkdir ucllcd ucllgit initecho ‘puts “Hello world”’ > hello.rbgit add hello.rbgit commit -m “Initial commit”

Start git project

echo ‘puts “Hello Craftworkz”’ > hello.rbgit status -sgit diffgit add hello.rbgit commit -m “update greeting”

Maak aanpassingen

git mv hello.rb hello2.rbgit commit -m “rename file”

Bestand hernoemen

echo “Temporary file” > tmpfilegit status -secho “tmpfile” > .gitignoregit add .gitignoregit commit -m “add gitignore”git status -s

Negeer bestanden

ls -algit rm hello2.rbgit status -s

git commit -m “delete file”

Verwijder bestanden

git log

git log --oneline

Bekijk history

Github

● Best place to share code!

● 9M gebruikers

● 21M repositories

“GitHub was born into a world where there was no existing market for paid Git hosting. We would be creating the market. I vividly remember telling people, “I don’t expect GitHub to succeed right away”

-- Tom Preston-Werner

git clone https://github.com/andyvdh/remotedemo.git

git remote -v

Clone Repository

git fetch origin

git merge origin

Haal veranderingen op

git pull origin

Haal veranderingen op + merge

echo “# Hello Remote 3” > README.md

git add README.md

git commit -m “update readme”

git push

Push naar remote server

git tag -a “0.0.1” -m “first tag”

git tag

git push --tags

Maak een tag

Maak een branch

git branch testing

git branch

Switch branch

git checkout testing

git branch

Werk verder op branch

echo ‘puts "Hello World"’> hello.rb

git add hello.rb

git commit -m “add greeting”

Terug naar master

git checkout master

cat hello.rb

Werk verder op master

echo ‘puts "Hello Craftworkz"’ > hello.rb

git add hello.rb

git commit -m “add new hello world”

GITK

IDE (Eclipse, IntelliJ, Visual Studio…)

Gitlab

SourceTree

Github for mac / windows

Gerrit

Samenvatting

● Leer de Command Line tool

● Gebruik altijd .gitignore file

● Push zaken die samenhoren, geef duidelijke commit messages

Best practices

● Check-in code min. 1x per dag

● Wees niet bang van branches

● Herschrijf de geschiedenis niet

Books

Pro Githttps://git-scm.com/book/en/v2

(Gratis)Pragmatic Guide To Git Git in Practice

THANK YOU!Feedback: #craftcamps