Workflow Git using GitHub?

9

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

I'm using linux (ubuntu) and would like to perform the operations via terminal. I already configured access to github via SSH.

I would appreciate it if the explanation is very detailed.

    
asked by anonymous 25.05.2015 / 19:14

2 answers

14

Documentation

I'll give you a brief explanation, but whenever there's any doubt, check out Git documentation .

I recommend these links with good explanations on the question:

Clone the Remote Repository

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

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

or

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

Workflow )

The basic workflow of Git can be described like this:

  • You modify files in your working directory ( working directory ).
  • You select the files by adding snapshots of them to your (staging area). For this you use git add .
  • You commit, which takes the files as they are in your preparation area and stores them permanently in your Git directory ( repository ). Using git commit .
  • Aftercommit,yourfileshavenotyetbeentotheGitHubrepository.Touploadthearchivesyouusethecommand git push , as shown below:

    git push origin master 
    

    To better understand the push for GitHub I recommend seeing this question Pushing from local repository to GitHub hosted remote from Stack Overflow.

    Practical Tutorial

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

        
    26.05.2015 / 14:58
    3

    First of all create a local repository in the preference folder 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 this the flow is as follows, there is the "Working Directory" that is where your files are, the "Index" that is the temporary area (where you will use git add) and the "HEAD" that is like if it was the area that sends it back to the online repository.

    You basically make the changes where you want, add the changes with

    git add *
    

    And then commit to the "HEAD":

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

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

    git push origin master
    

    It is a very generic example that I put, based on the pt-br guide, but that's how I learned it.

    Source: link

        
    25.05.2015 / 20:00