**git init** creates a new git repository" **git status** inspects the contents of the working directory and staging area **git add** adds files from the working directory to the staging area **git add -a** . the -a ensures even file deletions are included **git reset ** to remove a file or files from the staging area **git diff** shows the difference between the working directory and the staging area **git commit** permanently stores file changes from the staging area in the repository **git remote add origin https://github.com/nomutilisateur/monprojet** origin indicate a new place where files will be stored, remote describe origin and indicate that origin is distant, not local but online **git push -u remote_name branch_name** (git push -u origin master) pushes a local branch to a remote, the -u tells git to remember the parameters, so that next time we can simply run git push **git push** pushes the modifications to the distant repository github (remote) **git remote -v** lists all distant origins, remotes, your local git project knows (in other words it lists a git project's remotes) **git remote show origin** show the state of the remote and its branches **git remote rm remote_name** delete a remote **git remote set-url remote_name new_name** change remote name **git pull** pull any changes from the remote **git clone** creates a local copy of a remote **git branch** lists all a git project's branches **git branch branch_name** creates a new branch **git checkout branch_name** to switch from one branch to another **git checkout -b ** create and switch to new branch **git log** shows a list of all previous commits **git log --summary** show more informations **git merge branch_name** join file changes from branch_name into current branch **git branch -d branch_name** deletes the branch specified **git checkout commit_name** detach head from branch into commit, to move in commits **git checkout branch_name^** move head one commit upwards **git checkout branch_name~4** move 4 commits upwards **git checkout HEAD^** if head is not on a branch_name but on a commit **git branch -f master HEAD~3** moves the master branch to 3 parents behind head do not amend a public commit, it will reset the commit the others are working on **git commit --amend** do a commit replacing the last one, even if there was nothing to commit **git commit --amend --no-edit** do a new commit with new things replacing the last one and keepping the last message **git commit --amend -m 'message'** do a new commit that replace the last one with the same content but a new message **git stash** saves the uncommited changes besides for later use **git stash pop** reapply the stashed changes and removes them from the stash area **git stash apply** reaply the stashed changes and keep them in the stash area **git config --global credential.helper store** store the passwords in .git-credentials in the HOME directory (thanks to global, as opposed to the project directory) so you don't have tot type it each time **git config --global core.editor "vim"** change the git editor for vim **git cherry-pick NAME_OF_BRANCH** it merge a branch into the actual one, but only with the last commit **git --squash** https://stackoverflow.com/questions/23616706/git-squash-and-merge **git log --graph** show the graph of the commits with branchs **git log --first-parent master** show all the commits directly on master (or other branch) **relier dossier sur serveur en local avec git** **acceder au serveur via ssh :** `ssh hugugtzx@world-370.fr.planethoster.net -p 5022` **initier git dans le repo remote :** `git init` in the repo **dans le dossier local, cloner le repo :** git clone ssh://hugugtzx@world-370.fr.planethoster.net:5022/home/hugugtzx/wordpress.hugulumu.fr **avec :** git clone ssh://username@hostname/path/to/project avec `unsername@hostname` == la commande ssh et `/path/to/project` == la sortie de `pwd` dans le dossier remote