Gihub

De Memo
Aller à : navigation, rechercher

Commandes Vim

':w' sauvegarder le fichier
':q' quitter Vim
':x' sauvegarder et quitter Vim


Commandes générales



Status

git status

Activer git ds dossier courant

git init

Ajouter tous les fichiers d'un coup

git add

Commit

git commit -m "message;

Commit + add

git commit -am "message"

Afficher les commits

git log

Se placer sur un commit

git checkout 58b49ce1f7ef471f6f385e62338a5bd1061452c4

Revenir au dernier commit

git checkout master


Ajouter projet


Ajouter projet en provenance de github

git clone https://www.klklkddziiz

Envoyer vers github

git push origin master
git push -u origin master

Recevoir de github

git pull origin master


Branches


Savoir sur quelle branche on se trouve

git branch -a

Créer une branche

git branch mon-test

Se situer sur une branche

git checkout mon-test


Fusionner des branches


Fusionner branche "muliplication" avec la branche sur laquelle on se trouve

git merge multiplication

Créer une branche et se situer dessus

git checkout -b ma-branche

Supprimer une branche

git branch -d ma-branche


First push from local


At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. 
# Sets the new remote
git remote add origin remote repository URL
git remote add origin https://github.com/flabastie/memoword.git
# Verifies the new remote URL
git remote -v
# Pushes the changes in your local repository up to the remote repository
git push origin master


Divers


git symfony

http://symfony.com/fr/doc/current/cookbook/workflow/new_project_git.html

gitk

sudo apt-get install gitg gitk

allez dans la répertoire git

lancer gitg en l'occurence

git config --global user.name "xxxxxxxx"

git config --global user.email "xxxxxxxx@hotmail.com"


Suppression de fichier du cache

git rm --cached name_of_file


Sauvegarde du password

1. git config credential.helper store

2. Créer un fichier

3. git add *

4. git commit -m "test"

5. git push origin master

6. Mettre les infos une dernière fois

Git config

git config --global user.name "username"
git config --global user.email email
git config -l

Untrack files

Untrack files already added to git repository based on .gitignore

git rm -r --cached .
git add .
git commit -m ".gitignore fix"

branch

git fetch origin
git checkout --track origin/flabastie

Changer de branche

git checkout flabastie

Insérer fichier depuis autre branche

git checkout flabastie eco_diplomatie_main.ipynb

(depuis branche de destination)

Git Pull with overwrite

https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files
git fetch --all
git reset --hard origin/master

OR If you are on some other branch:

git reset --hard origin/<branch_name>

git fetch => downloads the latest from remote without trying to merge or rebase anything.

git reset => resets the master branch to what you just fetched.

The --hard option changes all the files in your working tree to match the files in origin/master

Change remote url

https://help.github.com/en/github/using-git/changing-a-remotes-url
git remote -v
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git

Update gitignore

Remove the cache of all the files

git rm -r --cached .

Remove the cache of specific file

git rm -r --cached <file_name.ext>