Um blog sobre nada

Um conjunto de inutilidades que podem vir a ser úteis

Git bash 101

Posted by Diego em Outubro 14, 2014


Quick tutorial on how to install Git, get data from a repository and push data to it.

Download and Installation:

 

1)   Download Git from: http://git-scm.com/downloads

2)      After you install it, there’s a chance it will start on a random folder (I’m pretty sure there’s  a logic behind it but I’m not sure what it is). In my case, it started on the M:\ drive on my network:

clip_image001[4]

 

3)      To set it to start on a particular folder just right click the shortcut, properties and set the “Start in” property to something like “c:\git”

clip_image002[4]

clip_image004[4]

 

 

4)      What you want to do net is to set a couple of global variables:

a.       Git config –global user.name “<username>”

b.      Git config –global user.email “<username>”

c.       Git config –list

 

 

Get data from a repository and push to it:

 

1)      Get data from a repository (called myfirsttest for example)

a.       Create the folder:

$ mkdir myfirsttest

b.      Inside the folder and init a repository:

$ cd myfirsttest /

$ git init

Message: Initialized empty Git repository in c:/git/test2/.git/

c.       Set the repository:

$ git remote add origin https://github.com/dmenin/myfirsttest.git

d.      Do the first pull:

$ git pull origin master

2)      Push changes to the repository:

a.       (touch bla.txt) #create a file

b.      $ git add –A

c.       $ git commit -m "first commit"  #commit message

d.      $ git push -u origin master #push requires autentication

 

3)      Other useful commands:

a. Check changes on a commit:
git show –pretty="format:" –name-only dbf476058d19b3f0772ae24adacf6f4e6c0fa6d3

2 Respostas to “Git bash 101”

  1. Diego said

    Adding an existing project to GitHub using the command line:

    https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

  2. Diego said

    Reblogged this on Um blog sobre nada and commented:

    Item 2.d should say:
    git push -u origin master

Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da WordPress.com

Está a comentar usando a sua conta WordPress.com Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s

 
%d bloggers like this: