Sei sulla pagina 1di 7

Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.

txt

Creare repository git su bitbucket

1) Una volta loggato scegliere il pulsante in alto "Create"


2) Impostare le opzioni similmante al file git_create.jpg
3) Se già non lo è selezionare il repository appena creato
4) Scegliere il pulsante clone e copiare il contenuto.
5) Sul computer locale avviare git, spostarsi nella cartella dei
repository, incollare ed eseguire il comando
6) Entrare nella cartella del nuovo repository
7) Creare uno o più file
8) git add --all
9) git commit -m "Primo commit"
10) git push origin master
con l'opzione origin master viene creato il branch matser sul
repository

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Per fare il pull forzando un'altro utente
1) Eseguire git pull oppure git pull origin master
2) Alla richiesta della password digitare invio
3) Verrà visualizzato il link al repository compreso il nome utente
4) modificare il link del punto 3 cambiando il nome utente con il proprio
per avere un risultato simile:
https://carmelomtb@bitbucket.org/treeweb/truecompany.git/info/refs
5) eseguire git pull https://carmelomtb@bitbucket.org/treeweb
/truecompany.git/info/refs
6) per eseguire il pull di un branch (ad esempio master):
git pull https://carmelomtb@bitbucket.org/treeweb/truecompany.git
/info/refs master

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Fare il merge:
Lavoro eseguito su dev da un'altra persona
1) git checkout dev (in locale ci si sposta sul branch dev)
2) git pull (si scaricano le modifiche apportate da un'altra
persona in locale)
3) git checkout master (in locale ci si sposta sul branch master)
4) git merge dev (in locale si fa il merge di dev su master, cioè
si copiano gli aggiornamenti di dev su master)
5) per aggiornare il master in remoto: git push

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
git rev-parse HEAD //Per vedere l'hash dell'attuale commit
git reset --hard HEAD~1 //Per annullare l'ultimo commit !!! Attenzione
elimina eventuali nuovi file e annulla tutte le modifiche ai file

1 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

git reset -- (annulla git add)file rimuove i file dallo stage; ovvero
copia i file dell'ultimo commit nello stage. Utilizza questo comando per
annullare un git add file.
Puoi anche utilizzare git reset per rimuovere tutto dallo stage.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Se il repo di default è settato per un altro utente
git remote add c2 https://carmelomtb@bitbucket.org/truelab/incontro-
nespresso.git
git pull c2 master

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Cambiare il commento di un commit
git commit --amend -m "New commit message"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Configurazione git
git config --list

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Errore git
warning: CRLF will be replaced by LF in eng/inc/contact_form.php.
find ./ -type f -exec dos2unix {} \;

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Annullare commit quando ancora non è stato eseguito push
git reset --soft HEAD^

In Git HEAD è la commit più recente mentre HEAD^ è la penultima (HEAD^^ è


la terzultima)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Annullare add file (git add prova.php)
git reset -- file prova.php
per annullare tutti gli add: git reset HEAD

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Duplicare repository in un nuovo repo

Repo originale classe-digitale-client


Nuovo repo vuoto classe-digitale-client-backup

2 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

git clone --bare https://carmelomtb@bitbucket.org/treeweb/classe-


digitale-client.git
cd classe-digitale-client.git
git push https://carmelomtb@bitbucket.org/treeweb/classe-digitale-client-
backup.git master
git push --mirror https://carmelomtb@bitbucket.org/treeweb/classe-
digitale-client-backup.git

++++++++++++++++++++++++++++++++++++++++++++++++++
Creare tag

git tag 2.3.0


git push --tags

tagn con annotazione


git tag -a 2.3.0 -m "testo"
git push --tags

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
git tag per i repo mip truelab

1) spostarsi sul branch dev: git checkout dev


2) fare le modifiche e committare: git add --all; git commit -m
"commento"
3) Aggiornare il file CHANGELOG.md mettendo l'elenco dei commit
4) Committare la modifica al file CHANGELOG.md mettendo come commento il
numero di release: git add --all; git commit -m "0.4.1"
5) aggiungere il tag (tipo annotated): git tag -a 0.4.1 -m '0.4.1'
6) Pushare le modifiche: git push (l'ordine di esecuzione dei punti 5) e
6) si può invertire non cambia niente)
7) Pushare il tag: git push origin 0.4.1
8) spostarsi sul branch master: git checkout master
9) fare il merge sul master: git merge dev
10) Fare il push: git push

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Riportare git alla versione corrente dopo git checkout "id commit" (ad
esempio git checkout b9e5e87)
git checkout master (o il nome del branch in cui ci si trova)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Release
Per vedere tutte le release o tag: git tag -l
Per vedere tag e relative annotazioni: git tag -n

It will list all the tags along with annotations & 9 lines of message for

3 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

every tag:

git tag -n9

can also use

git tag -l -n9

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
crea un nuovo branch chiamato "feature_x" e passa al nuovo branch usando
git checkout -b feature_x

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Aggiungere un sottomodulo

1) git submodule add https://carmelowise@bitbucket.org/wisemotions


/crypto.git src/main/java/wiseutility/crypto

git submodule add https://carmelowise@bitbucket.org/wisemotions


/audit.git src/main/java/wiseutility/audit
git submodule add https://carmelowise@bitbucket.org/wisemotions
/common-constant.git src/main/java/wiseutility/commonconstant
git submodule add https://carmelowise@bitbucket.org/wisemotions
/message-body.git src/main/java/wiseutility/messagebody
git submodule add https://carmelowise@bitbucket.org/wisemotions
/app-error-controller.git src/main/java/wiseutility/apperrorcontroller
git submodule add https://carmelowise@bitbucket.org/wisemotions
/log-mysql-v1.git src/main/java/wiseutility/logmysqlv1
git submodule add https://carmelowise@bitbucket.org/wisemotions
/telepass-exception.git src/main/java/wiseutility/telepassexception
git submodule add https://carmelowise@bitbucket.org/wisemotions
/telepass-oauth-2.git src/main/java/wiseutility/telepassoauth2
git submodule add https://carmelowise@bitbucket.org/wisemotions
/telepass-kafka.git src/main/java/wiseutility/telepasskafka
git submodule add https://carmelowise@bitbucket.org/wisemotions
/telepass-webclient-helper.git src/main/java/wiseutility
/telepasswebclienthelper
git submodule add https://carmelowise@bitbucket.org/wisemotions
/race-condition.git src/main/java/wiseutility/racecondition
git submodule add https://carmelowise@bitbucket.org/wisemotions
/splunk-log.git src/main/java/wiseutility/splunklog
git submodule add https://carmelowise@bitbucket.org/wisemotions
/app-error-controller-splunk.git src/main/java/wiseutility
/apperrorcontrollersplunk
git submodule add https://carmelowise@bitbucket.org/wisemotions
/telepass-oauth-2-splunk.git src/main/java/wiseutility

4 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

/telepassoauth2splunk

2) Committare (Non c'è bisogno di add --all dopo git submodule add)
git commit -m "Modulo aggiuntivo"

3) Pushare
git push

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Clonare un progetto con sottomoduli

1) git clone https://carmelowise@bitbucket.org/wisemotions/telepass-


tsp-2hire-java-server.git

2) cd telepass-tsp-2hire-java-server

3) git submodule init

4) git submodule update

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
Scaricare (pull) l'aggiornamento ad un sottomodulo

Da una delle directory del modulo padre


git pull
git submodule update

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Quando si ha l'errore:
'src/main/java/wiseutility/crypto' esiste già in index

dopo l'esecuzione del comando git "submodule add", ad esempio


https://carmelowise@bitbucket.org/wisemotions/crypto.git src/main
/java/wiseutility/crypto

Eseguire
git rm --cached src/main/java/wiseutility/crypto

Per rendere efficace il comando anche per le sotto cartelle usare


l'opzione -r
git rm -r --cached src/main/java/wiseutility/crypto

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Rimuovere un sottomodulo (non c'è un comando per rinominare la cartella)

git submodule deinit src/main/java/wiseutility/kafka


git rm src/main/java/wiseutility/kafka

5 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

rm -rf .git/modules/src/main/java/wiseutility/kafka

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Vedere l'lenco dei branch:
git branch -a

Eliminare un branch:
git branch -d develop

Eliminare da bitbucket un branch eliminato in locale:


git push origin :develop

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
git stash //salvare in un luogo temporaneo le modifiche per poter
cambiare branch

git stash show //mostare i file modificati che sono contenuti nel luogo
temporaneo, esempio:

.../main/java/com/wise/rca/expiration/zurich/inbound/api/rca
/CarInsuranceExpirationReadResourceImpl.java | 6 ++++--
.../src/main/java/com/wise/rca/expiration/zurich/client
/ZurichReadRcaRestClient.java | 3 +--
maven-multi-module/rca-expiration-zurich/src/main/resources
/application.properties | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)

git stash list //mostrare l'elenco dei salvataggi nel luogo temporaneo,
esempio:

stash@{0}: WIP on new-response-type: a608b27 fix jacoco and add some


tests

git stash apply //caricare all'attuale branch le modifiche presenti nel


luogo temporaneo, esempio dopo git stash apply:

On branch fix-client
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working
directory)

modified: rca-expiration-zurich-adapter-inbound/src/main/java
/com/wise/rca/expiration/zurich/inbound/api/rca
/CarInsuranceExpirationReadResourceImpl.java
modified: rca-expiration-zurich-client/src/main/java/com/wise
/rca/expiration/zurich/client/ZurichReadRcaRestClient.java

6 di 7 08/04/23, 17:54
Firefox file:///Users/carmelo.catalano/Dati/Guide/git/git.txt

modified: rca-expiration-zurich/src/main/resources
/application.properties

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
Rinominare branch

git checkout old_name

Rename the local branch by typing:

git branch -m new_name

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
Sovrascrivere intero branch
https://gist.github.com/ummahusla/8ccfdae6fbbe50171d77

# overwrite master with contents of feature branch (feature > master)


git checkout feature # source name
git merge -s ours master # target name
git checkout master # target name
git merge feature # source name

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++
No stop dopo git branch -a
git config --global pager.branch false

7 di 7 08/04/23, 17:54

Potrebbero piacerti anche