Pour gérer son code seul ou à plusieurs Git est devenu un must-have.

Je vous ai fait une petite compilation sous forme de memo des commandes Git que j'utilise le plus.

Pour information j'utilise Bitbucket mais cela marche avec tous types de serveurs Git (GitHub, GitLabs, etc).

J'ai également mis quelques lignes de git-ftp qui permet d'envisager du continuons delivery chez des hébergeurs de sites Web (avec des workflow Jenkins, GitLabs CI, Bitbucket pipelines, etc).

Allez en piste et finis les trous de mémoire :)

# Initialize
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin https://myusername@bitbucket.org/myusername/repository.git
git add *
git commit -a   # e.g. 'Importing'
git push -u origin master

# Add / Commit / Push ALL
git add *
git commit -a
git push

# Retrieve elsewhere / Update from repo
git clone https://myusername@bitbucket.org/myusername/repository.git /path/to/your/project
git pull

# Branches
git checkout -b newWidget  # create branch
git branch                 # display branches and see active branch
git checkout branchX       # switch branch
git commit -m 'blah'       # commit once switched
git push origin branchX    # push on the branch
git show :readme.txt       # show current branch's file
git show banchX:readme.txt # show file from a specific branch
git merge branchX          # merge branch

# Troubleshooting
## Problem with the SSL CA cert (path? access rights?)
apt-get install ca-certificates

# Git FTP
git ftp catchup -u xxxxxxxx -p xxxxxxxx ftp://ftp.example.com # instead of git ftp init if file already on the remote FTP server
git ftp push -D -u xxxxxxxx -p xxxxxxxx ftp://ftp.example.com # push (dry-run)
Tag(s) : #git
Partager cet article
Repost0
Pour être informé des derniers articles, inscrivez vous :