Git workflow (workflow) using Github?

Asked

Viewed 598 times

9

I need to learn how to clone a project from github to my local computer and, after making the necessary changes, send the modifications back to the remote project. Basically the workflow git by using Github.

I am using linux (Ubuntu) and would like to perform terminal operations. I have already set up github access via SSH.

I would be grateful if the explanation is very detailed.

  • See if this helps you: https://try.github.io

  • This helps me learn Git, so much so that I’ve completed the exercises on this site. I wonder what the workflow is like using github via linux terminal.

  • For a more complete workflow like using the gitflow. It might include an answer with him, but if someone qualifies...

  • @gmsantos get excited, can put yes. Every good answer is welcome! ;)

  • 1

    I’m at work now, and here I don’t have access to use it, only at home :)

2 answers

14


Documentation

I will make a brief explanation, but whenever there is doubt, please refer to git documentation.

I recommend these links with good explanations about the question:

Clone the Remote Repository

The first thing to do is to clone the remote repository in the desired location using the git clone as examples below:

git clone [email protected]:nomeusuario/nomeprojeto.git

or

git clone https://github.com/nomeusuario/nomeprojeto.git

Workflow (Workflow)

The workflow basic Git can be described like this:

  1. You modify files in your working directory (Working directory).
  2. You select the files by adding snapshots of them to your area preparation (staging area). For this you use the git add.
  3. You commit, which takes the files as they are in its preparation area and stores them permanently in its git directory (Repository). Using the git commit.

inserir a descrição da imagem aqui

After the commit, your files have not yet gone to the Github repository. To upload the files you use the command git push, as an example below:

git push origin master 

To better understand push for Github I recommend seeing this question Pushing from local Repository to Github Hosted remote stack overflow.

Tutorial

As indicated in the question’s comments, a practical tutorial that can help you understand the main concepts of git is Git Tutorial.

3

First of all create a local repository in the folder preferably with:

git init

This will create a. git in the folder for git to recognize as a repository.

The flow I learned was this:

Clone the repository:

git clone https://github.com/meunome/meurepositorio

After that the flow is as follows, there is the "Working Directory" which is where your files are, the "Index" which is the temporary area (where you will use git add) and the "HEAD" which is like the area you send back to the online repository.

You basically make the changes wherever you want, add the changes with the:

git add *

And then do the "head":

git commit -m "comentários das alterações"

It will be in "HEAD", to send back to the source repository:

git push origin master

It’s a very generic example that I put up, based on the en guide, but that’s how I learned.

Source: http://rogerdudler.github.io/git-guide/index.pt_BR.html

  • 1

    Man, very good. thank you. I will also put a more detailed reply that I found on another site.

  • Why initialize a repository of something that will soon be cloned? It would only be necessary to start a local repository to get to work and then associate it to a remote, no?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.