Skip to content

Instantly share code, notes, and snippets.

@b-ma
Created November 30, 2013 12:38
Show Gist options
  • Save b-ma/7718550 to your computer and use it in GitHub Desktop.
Save b-ma/7718550 to your computer and use it in GitHub Desktop.
common git commands
======================================================
GITHUB
======================================================
recap pour utlisation de git et github :
* * * * * * * *
* CREATION *
créer un repo sur sa machine
```bash
$ cd my/folder/project
$ git init
```
> note : penser à créer un fichier ```.gitignore```
> note : on part du principe que tout se passe dans le dossier
> courant du projet
recupérer un repo existant sur github
```shell
$ git clone project_link.git
```
enregistrer "origin" (repo du serveur) :
```shell
$ git remote add origin server_link.git
```
* * * * * * * *
* UTILISATION COURANTE *
> note: le "stagging" est flou mais il existe
voir la liste des fichiers en attente de stagging et/ou de commit
```shell
$ git status
```
ajouter un ficher en stagging
```shell
git add nom_du_fichier
```
variantes plus pratique
```shell
# ajouter tout les fichier updatés d'un coup
$ git add -u
# ajouter tout les fichiers updatés ou crés d'un coup
$ git add .
```
enlever les fichiers supprimés du repo
```shell
$ git rm nom_du_fichier
# ou tous d'un coup
$ git rm $(git ls-files --deleted)
```
passer tout ce qui se trouve en stagging dans le commit
```shell
$ git commit -m 'mon message'
```
pousser le tout sur le repo distant
```shell
$ git push origin my_branch
```
récupérer les mises à jours des autres
```shell
$ git pull origin my_branch
```
* * * * * * * *
* LES BRANCHES *
lister les branches
```shell
$ git branch nom_de_branche
```
créer une branche
```shell
$ git branch nom_de_branche
```
supprimer une branche
```shell
$ git branch -d nom_de_branche
```
changer de branche
```shell
$ git checkout branche_ou_je_vais
# créer une branche et s'y rendre d'un seul coup
$ git checkout -b nom_de_ma_branche
```
merger une branche dans une autre
```shell
$ git checkout branche_cible
$ git merge branche_fille branche_cible
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment