samedi 5 mars 2016

Git basics (1st part)

GIT BASICS

Initialise a git repository 

$ git init .
this will create a git structure into the current directory.

Adding files

$ git add -A .
This (-A) will add all file including sub directories to the current branch (master) by default.

1st commit

$ git commit -m  "my first commit "
-m allow you to add a comment which will be visible  later.
The commit is performed locally so the remote repository will not be update (see push section below).

Create a branch

$ git checkout -b mybranch
this will create a branch "mybranch" and move git on it

 

Show all branches

$ git branch -v
this will show you all branches with commit logs. the * sign show which branch you are on.


Switch branch
$ git checkout mybranch
this will move you to mybranch


Add a remote repository
$git add remote orgin master http://....
this will add the branch master http://... as a remote repository (with the name orgin)


Push to a remote repository
$git push origin master
this will push the current branch to the remote repository origin branch master


Clone a remote repository
$git clone http://... target_folder
This is explicit enough





Aucun commentaire:

Enregistrer un commentaire