# Many users

Git was originally created by Linus Torvalds as a versioning system for the linux kernel in which thousands of developers collaborate. Git is meant to make collaboration easy.

There are different workflows to collaborate on a git repo, but the simplest and most beginner friendly is to:

  • Create a repository and upload it to github (gt init).
  • Send invites to collaborate on your repo to your teammates through your repo’s settings on github.
  • Every team member downloads a copy of the repository (git clone).
  • Every team member works on their local repo, saves checkpoints and uploads them to github so their changes are visible to everyone on the team, they also download changes uploaded to github by other team members (gt save).

# Sending invites for collaboration

Once a repo is stored on github as a public repository, anyone can download it. Only those invited to collaborate can upload code to it. In order to give another user write permissions for your repo you need to make them a collaborator (on your repo’s page on github → Settings → Manage access → Invite a collaborator).

Invite collaborators

# Downloading a copy of a repository on github

If you want to work on someone else's repo or download your own repo into another computer, you need to clone the repository. To achieve this, you can grab the repo’s url from the "code" button in its GitHub page.

Clone a repo

Then on your terminal type:

$ git clone 

(note that you are using git not gt)

# Example

For instance if you type

$ git clone https://github.com/artemisa-mx/demoRepository.git

git will create a folder called demoRepository and inside of it you’ll have a repository that is a copy of Artemisa-mx's demoRepository.

# Saving changes

Once you have a local copy of a github repository in your machine (or created one with gt init), gitutor will sync the local and remote repositories everytime you create a checkpoint with

$ gt save

This command will create a commit of the state of your local repo, update your local repo with new commits downloaded from github (if any exist) and upload your new commits to github.

# Merge Conflicts

In the process of incorporating new commits from github into your local repo, git may be unable to figure out how to put both versions together, this is called a merge conflict, which may occur when competing changes are made to the same line of a file.

Git will show you where the conflicts happen in a file with special marks (>>>>> and <<<<<). For convenience it will write the current version of your local repository and below it the version of the remote repository. To solve the conflict select which version you want and delete the other one, including the conflict marks

For example, if one of your files has a conflict you’ll find the following markers:

    <<<<<<< HEAD
    This is the local version
    =======
    This is the remote version
    >>>>>>> 23mk2k495sj1k34

To solve the conflict, delete the marks and the version you don’t want to keep. For example, if we want to keep the local version, the file will be like this

    This is the local version

And that’s all! 😃

Modern IDE's like VScode provide a graphical interface to solve merge conflicts that deletes the conflict markers automatically, we recommend you use one.

Visualize conflic in IDE

In the case of merge conflicts, Gitutor will output the name of the files with conflict markers. If you dont want to resolve the conflicts right away you can abort the attempt to sync with the remote repository by running:

$ gt save --defer-conflicts

Your repo will return to how it was before the merge conflict and your checkpoint will be saved on your local machine only. You won't lose any work.

# Summary

  1. Create (gt init) or clone a repo.
  2. Work on your project.
  3. Create checkpoint to save changes (gt save).
  4. If no conflict occurs go to step 2.
  5. If a merge conflict occurs, gitutor will output the names of the conflicted files. Solve the conflicts and then create a checkpoint to save the conflict resolution (gt save). If you don't want to resolve conflicts right away, defer conflict resolution( gt save --defer-conflicts)

It's worth noting that in the case you missed to solve a conflict, gitutor will remind you when you try to create a new checkpoint. If you don’t want to riks creating a merge conflict at a particular moment you can save a checkpoint only on your local repository with:

$ gt save -l

Your current changes will only be saved on your machine not on github. Later you can sync again your repo with github using gt save.

*If you are cloning a repo you don’t need to execute gt init