Git Cheat Sheet

De wiki-fabmstic
Version datée du 20 septembre 2017 à 10:08 par Germain (discussion | contributions)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Aller à la navigation Aller à la recherche

Create

Create a new repository If your using https://gitlab-fabmstic.imag.fr/ see the specificities Git and GitLab basics

git clone https://gitlab-fabmstic.imag.fr/fablab/test.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin https://gitlab-fabmstic.imag.fr/fablab/test.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote add origin https://gitlab-fabmstic.imag.fr/fablab/test.git
git push -u origin --all
git push -u origin --tags

Get change

Get the change from the server

git pull

Add change

Add changes of a file or a directory to the next commit

git add /path/to/file
git add /path/to/directory

Commit the previously staged changes, add meaningfull comments

git commit

Push change to origin (the server)

git push

Shortcut

Commit the previously staged changes with the commit comments

git commit -m"meaningful comments"

Add all changes of modified files and commit them

git commit -a