Skip to content

Using Git

ManelMCCS edited this page Sep 8, 2022 · 1 revision

Using Git and GitHub

Getting started

Installation

  1. Install git on your PC. (Installing Git tutorial)

  2. Message the chair of the Student Branch throw slack to join the RAS Team on GitHub. To have permission to write to this repository.

Credentials

  1. With the git config command set up your GitHub username and email:
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
  1. Create a personal access token (Creating a personal access token tutorial).

  2. Use git credential manager More about Git Credential Manager

git config --global credential.credentialStore gpg

Copy the repository into a new directory

  1. Open the terminal in the directory you want to save the project in your computer. Use git bash if you are using windows.

  2. After install git you need to clone the repository (git clone documentation):

git clone https://github.com/ieeeupsb/nemo

Workflow and general practices

General workflow

  1. Go to the feature branch.
  2. Commit and push our changes.
  3. Update the master repository using pull requests.

Use different branch for parts or features.

Branches allow you to work on different parts of a project without impacting the main project.

Deciding on a correct branching strategy is vital to streamlining the commit process. Whatever your strategy, communicate to the team how you want to branch. You also want to use smaller, short-lived branches. Using this method has proven to minimize organization problems.

Commit small changes.

By committing only small sections of code, everyone on your team can quickly understand what work has been completed. And if something goes wrong, smaller commits make it easier to revert bad check-ins, which helps you maintain a stable codebase.

When writing a commit message, start with a short summary of your change. Write your summary in present tense, limit the subject line to 50 characters, and always leave the second line blank. This separates your subject line from the message to ensures only the subject line displays.

Update the main repository

Use pull requests. Try not to include some additional stuff into the PR. For example, do not fix any typos other than your current context or do not add a tiny bug fix to a feature. In this way, you can easily describe your aim and prevent confusion. You can also eliminate the possibility of one change waiting for the other.

TODO pull request template

Basic commands

Update to the code lastest version

  1. Use the fetch command. The git fetch command downloads objects to the local machine without overwriting existing local code in the current branch. The command pulls a record of remote repository changes, allowing insight into progress history before adjustments.
git fetch origin (download objects and refs from the repo)
  1. (Optional) Reset the branch to origin.
git reset origin
  1. Incorporate change from the remote repository into the current branch.
git pull 

Change between parts or feature

Go to branch of the feature or part you want to work.

git checkout <feature_name>

Commit your changes and update the remote repository.

  1. Check for changes.
git status
  1. Add the files you want to commit.
git add <some-file>
git commit
  1. Commit and write the message using the general practices.
git commit
  1. Use git push updates the remote branch with local commits. It is one of the four commands in Git that prompts interaction with the remote repository. You can also think of git push as update or publish.
git push

Modules

git submodule add <MODULE_REPO> styles/module