User Tools

Site Tools


github

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
github [2018/05/02 19:51] jefersongithub [2019/03/15 13:20] (current) – [- Initializing git from a previously created local repository] pericles
Line 1: Line 1:
-For a complete tutorial of Github usage [[https://tableless.com.br/tudo-que-voce-queria-saber-sobre-git-e-github-mas-tinha-vergonha-de-perguntar/|click here]].+====== Git ======
  
-Important commands:+Git is a system for version and shared edition control of codes. GRUMEC uses Git for registering the edition history of computational mechanics implementations and scientific papers writing in LaTeX.
  
-<file>+===== GitHub ===== 
 + 
 +//GitHub// is an online platform where you can host and share your git repositories and projects. After git is installed in your machine, it is necessary to configure an username and an email. [[https://help.github.com/en/enterprise/2.16/user/articles/adding-a-new-ssh-key-to-your-github-account|https://help.github.com/en/enterprise/2.16/user/articles/adding-a-new-ssh-key-to-your-]]github-account 
 + 
 +<code> 
 +git config --global user.name ["username"
 + 
 +git config --global user.email ["email"
 +</code> 
 + 
 +There are two basic ways of synchronizing a local repository to a remote one: 
 + 
 +==== - Initializing git from a previously created local repository ==== 
 + 
 +Open terminal and navigate to the local repository folder. Then type 
 + 
 +<code> 
 +git init 
 +</code> 
 + 
 +This will initiate git in your program. However, git does not know yet the files that you want to be tracked. To do this, you need to use the command 
 + 
 +<code> 
 +git add [filename] 
 +</code> 
 + 
 +If you want all the files to be tracked by git, just use a "." after the command add. These files will now be tagged as "staged", which means that they are recognized by git but was not commited yet. In order to commit a change in a document, one can use the command 
 + 
 +<code> 
 +git commit -m ["message"
 +</code> 
 + 
 +For example, let's assume that you just tested your FEM code for the static case, however you did not finish yet the implementation of the dynamic part. Then you can use the following command: 
 + 
 +<code> 
 +git commit -m ["Static problem tested. Need to finish the dynamic part implementation"
 +</code> 
 + 
 +If you are responding to an issue (let's say, issue #1), then you can use the following command: 
 + 
 +<code> 
 +git commit -m ["Static problem tested. Need to finish the dynamic part implementation"] #1 
 +</code> 
 + 
 +This will allow you to know exactly how the code was when you commited a change. Although the local repository is being tracked by git, it is not linked with a remote repository like github for instance. We can do that by calling: 
 + 
 +<code> 
 +git remote add origin [repository-location] 
 +</code> 
 + 
 +in which repository-location is the weblink to the remote repository, for example [[https://github.com/username/repository-name.git|https://github.com/username/repository-name.git]]. Now your local repository is synchronyzed with github, and every commit can be pushed to the remote repository by typing 
 + 
 +<code> 
 +git push origin [branch] 
 +</code> 
 + 
 +and your github username and password will be requested. 
 + 
 + 
 +==== - Cloning an existing remote repository ==== 
 + 
 +When there is an existing remote repository and you want to clone it to your machine and start working on it, you can do this by means of 
 + 
 +<code> 
 +git clone [repository-location] [folder] 
 +</code> 
 + 
 +considering repository-location the source link to the remote repository you are cloning and folder is an optional argument if you want to specify the folder in your computer where the repository will be located in. 
 + 
 +Whenever you want to check either if a file is being tracked or if there are unsaved changes, you can use the command 
 + 
 +<code>
 git status git status
 +</code>
  
-git add+==== Branches ====
  
-git commit -m "comment"+A branch indicates how the code flows. It is really helpful for co-works and when several people work simultaneously in a same code. When a new repository is created, usually it has only the branch master. To create new branches the command is
  
-git push+<code> 
 +git checkout -b [branch name] 
 +</code>
  
-git pull+by doing this the code flow is divided in two branches: master and a new one. Every change that you make in the new branch, the master one will remain intact. Suppose that after several changes you would like to merge the branches again. This can be performed by typing:
  
-git checkout <branch>+<code> 
 +git merge [branch name] 
 +</code>
  
-git merge <branch+By doing that, those two branches become just the master again,and every change that were previously made in the alternative branch are transferred to master as well.
-</file>+
  
-''Research group codes hosted on Github: ''+Research group codes hosted on Github:
  
-''- [[https://github.com/jefersondossa/FSArl|Fluid-Structure interaction using the Arlequin method]]; ''+- [[https://github.com/jefersondossa/FSArl|Fluid-Structure interaction using the Arlequin method]] (criar conta no GitHub e solicitar acesso com Jeferson);
  
  
github.1525290671.txt.gz · Last modified: by jeferson