Skip to content

How to Git

Leonardo Azzi Martins edited this page Nov 27, 2018 · 3 revisions

This is our repository! Yay!

  • First of all, you must have the repository in your machine.

  • Download Git here and install it.

  • After that, choose a directory in your PC to put the SmartLeg folder.

  • So, click with the right mouse button in the folder and click in "Git Bash Here".

  • This is our Bash. In it, we can manage our repository and write commands. We must clone the repository in your machine. So, in Bash, insert git clone https://github.com/SmartBionics/SmartLeg.git.

  • The repository must be copied in your machine.

  • Git have many timelines of versions, like time-space. That's the advantage of using Git. This is called branch. There is the master branch, the main one, that must be always no the top. Master is our main timeline, our most updated code.

  • But everytime you want to modify a code or anything in directory, you must create a new timeline, a new branch. To create a new branch, you can insert in batch the command git checkout -b <BRANCH_NAME>. Your new branch will copy the master and will allow you to modify your files without changing directly master.

  • When you are done with your coding, you can get a git status. Every modifications in your branch will be listed. But they are not tracked. To track the modifications, you must do a git add <FILEPATH> or, with you want to add all, git add .. If you want to untrack or remove a file, you must do a git remove <FILEPATH> or git remove . to remove all.

  • After that, you are ready to make a commit. The commit is a compilation of your modifications in a limited scope, to help we organize your version management. For example, if we have a lot of codes, it's preferable if you make small commits. If you are making just one thing, one code, one or more tasks correlated, you should do just one commit. Commits are little fragments of modifications, so we can have a backup and visualize the diff between modifications.

  • Now, you must make the commit using git commit -m <MESSAGE>. You must write a simple message, like a changelog, explaining briefly your modifications.

  • Afther the commits - or many of it - you must create a pull request. The pull request is the part that we make our code available for review. For that, you just make a git pull. The link to open the pull request in GitHub will be available in bash.

  • So, with pull request opened, our team can review your code, point errors, make comments and indicate TO-DOs. Also, the team can approve or reject the pull request. This is possible looking the diff page that compares what is in master with your branch. Once the pull is approved by all review team, one reviewer must click in merge the pull request. Now, your modifications are merged in master!

  • Everytime you make changes in your branch and makes a commit, the first pull request of that branch will be just updated, and will not open a new one. So, if you want new pull requests, you must always create new branches from master.

  • And everytime some modification of your teammate is approved and merged in master, you must make a rebase in your branch, to download the modifications. I don't tested this function yet.

To be continued...