Skip to content

Instantly share code, notes, and snippets.

@maxdevel
Forked from carlopecchia/git_short_tutorial-it.sh
Created December 5, 2008 23:19
Show Gist options
  • Save maxdevel/32555 to your computer and use it in GitHub Desktop.
Save maxdevel/32555 to your computer and use it in GitHub Desktop.
# iniziamo creando una nuova applicazione Rails
rails silly_blog
cd silly_blog
# portiamola sotto version control con Git
git init
git add .
git commit -a -m "first commit"
# siamo nel "master" branch
git branch
# apportiamo delle modifiche (es: aggiungiamo un nuovo modello)
ruby script/generate model Post title:string body:text
git add .
git commit -a -m "added post model"
# il log riflette tutti i commit effettuati
git log
## Aggiungiamo una feature "esperimentale"
# nuovo branch
git branch experimental
git checkout experimental
ruby script/generate model Rating value:integer post:references
git add .
git commit -a -m "added rating model"
git checkout master
# riportiamo le modifiche della nuova feature nel "master" branch
git merge experimental
## apportiamo una modifica nel branch "experimental", senza farne una commit
git checkout experimental
# modifichiamo il modello Rating
cat "class Rating < ActiveRecord::Base; belongs_to :post; end" > app/models/rating.rb
git checkout master
git status
# la modifica ha sporcato anche il "master" branch
# torniamo nel branch "experimental" e facciamo un commit
git checkout experimental
git commit -a -m "now ratings belong to posts"
git checkout master
git status
grep "belongs_to" app/models/rating.rb
# la modifica è rimasta nel branch "experimental",
# per importarla basta il consueto:
git merge experimental
## Gestione dei conflitti
# aggiungiamo il nuovo file TODO nel branch "master"
echo "#List of next actions to accomplish" > TODO
git add .
git commit -a -m "added a (empty) list of next actions"
git checkout experimental
# notiamo che qui *non* esiste il file TODO
# importiamo le modifiche (più recenti) fatte
git pull . master
# aggiungiamo un'azione (in "experimental")
echo "* write unit tests" >> TODO
git commit -a -m "added some action"
# aggiungiamo un'azione (in "master")
git checkout master
echo "* buy milk" >> TODO
git commit -a -m "remember the milk"
# adesso le due versioni di TODO sono in conflitto
git checkout experimental
git pull . master
# viene generato un conflitto sul merge!
echo "#List of next actions to accomplish" > TODO
echo "" >> TODO
echo "* write unit test" >> TODO
echo "* buy milk" >> TODO
git commit -a -m "resolved conflicts on next things to accomplish"
git checkout master
git merge experimental
# tutto allineato
# Rimuoviamo l'applicazione
cd ..
rm -fr silly_blog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment