viernes, 10 de julio de 2015

GIT

Git tutorial:
http://www.vogella.com/tutorials/Git/article.html

Just to know
  • Bare Repository: A remote repository on a server typically does not require a working tree. A Git repository without a working tree is called a bare repository. are used on servers to share changes coming from different developers
  • No-bare Repository: Allow you to create new changes through modification of files and to create new versions in the repository
  • Always need to initialize a git repository before call any commands

Creating Bare repository (shared/server repository)
  • git --bare init

Creating Non-bare repository (local?developer repository)
  • git init

Global Configuration (applies to all repositories)
  • Configure your user and email for Git
  • # configure the user which will be used by Git
  • # this should be not an acronym but your full name
  • git config --global user.name "Firstname Lastname" 
  • # configure the email address 
  • git config --global user.email "your.email@example.org"
  • Configures Git to push only the active branch ( for older versions )
  • # set default so that only the current branch is pushed
  • git config --global push.default simple 

Adding remote repository
  • Inside the non-bare repository type the following command:
  • git remote add origin /home/etc/repo.git
  • git remote add origin http://bla.com/github/bla

List the remote repository (in the non bare repository)
  • git remote -v

Pushing from the non-bare (developer) repository to bare (shared) repository
  • git add .
  • git commit -m "init commit"
  • git push origin master
origin=>the name of the repo
master=>the default branch


Cloning from the bare repository to non-bare repository
  • Initialize a git non bare repository
  • $ git init
  • Initialized empty Git repository in /home/Damian Ciocca/clone.git3/.git/
  • $ git remote add origin /home/etc/repo.git
  • $ git clone /home/Damian\ Ciocca/repo.git/ repo
  • Cloning into 'repo'...
  • done.

Pulling from the bare repository to non-bare repository
  • git pull orifin master

Another commands
  • git log
  • git status -s
  • git remote -v