How do I connect remotely in Git

3

I already know what we use versioning, how to do commits, add new files, logs, etc. but I would like to upload my files to the Github repository online, how do I connect and send my files?

    
asked by anonymous 05.02.2014 / 18:19

2 answers

2

Alexander, I assume you already have an account on GitHub ...

Then it's the following:

  • First generate the ssh key pair: ssh-keygen -t rsa

PS: If you do not have ssh , you should install

  • You create a repository in GitHub for this project
  • Copy to url it generates. Something like: link

  • Then in your local git, give the command: git remote add origin https://github.com/usuario/nome_do_projeto.git

PS: origin is just a default name you can put any name. It will be the name of your remote repository

  • Then you give the command: git push origin master
  • Inform the password and you're done.
05.02.2014 / 18:30
3

Configure the GIT client, to link the commits to the correct name (Commits author)

git config --global user.name "SEU NOME AQUI"
git config --global user.email [email protected]

To initialize the empty GIT repository there are two ways.

[1] By executing the command below, git will create the folder, if it does not exist and initialize as a GIT repository. Ex:

~$ git init name_project

[2] Creating the folder and then entering the folder and then initializing the repository would look like this:

~$ mkdir name_project
~$ cd name_project
~$ git init

Log into your repository and create the README file

~$ cd name_project/
~$ vim README

Type initial text, such as "First commit" and save the file (: wq)

~$ git status

The data as shown below will appear, but what does this mean? Well, the important part of this screen is Untracked files that shows the files that the GIT is not yet managing, that is, the GIT does not know what to do with it and does not register any modifications to the file.

Then just add and commit the file:

~$ git add README
~$ git commit -m "Adicionando arquivo README"

Next step is to upload to the repository with:

~$ git push

If you want to download on a server or another computer use the command:

~$ git clone [url]

(this url is given in the directory that was created)

After cloning to download updates use:

~$ git pull
    
05.02.2014 / 18:23