banner



How To Add Collaborator To Github

Collaborating

Overview

Didactics: 25 min
Exercises: 0 min

Questions

  • How can I utilise version command to collaborate with other people?

Objectives

  • Clone a remote repository.

  • Collaborate by pushing to a common repository.

  • Describe the basic collaborative workflow.

For the next stride, get into pairs. One person volition be the "Possessor" and the other volition be the "Collaborator". The goal is that the Collaborator add together changes into the Owner'due south repository. We will switch roles at the finish, so both persons will play Possessor and Collaborator.

Practicing By Yourself

If you're working through this lesson on your own, you can comport on by opening a second last window. This window will stand for your partner, working on another computer. You won't need to give anyone access on GitHub, because both 'partners' are you lot.

The Owner needs to give the Collaborator access. On GitHub, click the settings button on the right, select Manage access, click Invite a collaborator, and then enter your partner's username.

Adding Collaborators on GitHub

To accept access to the Owner'due south repo, the Collaborator needs to go to https://github.com/notifications or check for email notification. In one case there she can accept access to the Owner'south repo.

Side by side, the Collaborator needs to download a copy of the Owner's repository to her machine. This is called "cloning a repo".

The Collaborator doesn't desire to overwrite her own version of planets.git, so needs to clone the Owner's repository to a dissimilar location than her ain repository with the same name.

To clone the Owner'southward repo into her Desktop binder, the Collaborator enters:

                          $              git clone git@github.com:vlad/planets.git ~/Desktop/vlad-planets                      

Replace 'vlad' with the Owner'southward username.

If y'all choose to clone without the clone path (~/Desktop/vlad-planets) specified at the cease, you lot volition clone inside your ain planets folder! Make certain to navigate to the Desktop folder outset.

After Creating Clone of Repository

The Collaborator tin can now make a change in her clone of the Owner's repository, exactly the same way as we've been doing earlier:

                          $                            cd              ~/Desktop/vlad-planets              $              nano pluto.txt              $                            cat              pluto.txt                      
                          $              git add pluto.txt              $              git commit              -grand              "Add together notes about Pluto"                      
                          1 file changed, 1 insertion(+)  create mode 100644 pluto.txt                      

Then push the change to the Owner'south repository on GitHub:

            Enumerating objects: iv, washed. Counting objects: iv, done. Delta compression using up to 4 threads. Compressing objects: 100% (two/2), washed. Writing objects: 100% (3/3), 306 bytes, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/vlad/planets.git    9272da5..29aba7c  primary -> main                      

Note that nosotros didn't have to create a remote called origin: Git uses this name by default when we clone a repository. (This is why origin was a sensible choice earlier when nosotros were setting upwards remotes by hand.)

Take a look at the Owner's repository on GitHub again, and y'all should be able to see the new commit made past the Collaborator. You may need to refresh your browser to run across the new commit.

Some more about remotes

In this episode and the previous 1, our local repository has had a single "remote", called origin. A remote is a copy of the repository that is hosted somewhere else, that we tin push to and pull from, and at that place's no reason that you have to work with simply one. For example, on some large projects you might have your own copy in your ain GitHub account (you'd probably call this origin) and also the main "upstream" project repository (let'due south call this upstream for the sake of examples). Y'all would pull from upstream from time to time to become the latest updates that other people have committed.

Remember that the name y'all give to a remote only exists locally. Information technology'due south an allonym that you choose - whether origin, or upstream, or fred - and not something intrinstic to the remote repository.

The git remote family of commands is used to set up and alter the remotes associated with a repository. Here are some of the about useful ones:

  • git remote -v lists all the remotes that are configured (we already used this in the last episode)
  • git remote add [name] [url] is used to add a new remote
  • git remote remove [name] removes a remote. Annotation that information technology doesn't bear upon the remote repository at all - it just removes the link to it from the local repo.
  • git remote fix-url [proper name] [newurl] changes the URL that is associated with the remote. This is useful if it has moved, e.yard. to a different GitHub business relationship, or from GitHub to a different hosting service. Or, if we made a typo when calculation information technology!
  • git remote rename [oldname] [newname] changes the local allonym by which a remote is known - its proper noun. For case, one could use this to alter upstream to fred.

To download the Collaborator'due south changes from GitHub, the Owner at present enters:

            remote: Enumerating objects: 4, done. remote: Counting objects: 100% (iv/4), washed. remote: Compressing objects: 100% (2/2), washed. remote: Total 3 (delta 0), reused iii (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/vlad/planets  * branch            master     -> FETCH_HEAD    9272da5..29aba7c  main     -> origin/master Updating 9272da5..29aba7c Fast-forward  pluto.txt | 1 +  1 file inverse, one insertion(+)  create mode 100644 pluto.txt                      

Now the three repositories (Owner's local, Collaborator's local, and Possessor'south on GitHub) are back in sync.

A Basic Collaborative Workflow

In practice, it is skillful to exist sure that you have an updated version of the repository you are collaborating on, so you should git pull earlier making our changes. The basic collaborative workflow would be:

  • update your local repo with git pull origin main,
  • make your changes and stage them with git add,
  • commit your changes with git commit -one thousand, and
  • upload the changes to GitHub with git push origin principal

It is better to make many commits with smaller changes rather than of one commit with massive changes: small commits are easier to read and review.

Switch Roles and Echo

Switch roles and echo the whole procedure.

Review Changes

The Possessor pushed commits to the repository without giving any information to the Collaborator. How can the Collaborator discover out what has inverse with control line? And on GitHub?

Solution

On the command line, the Collaborator can use git fetch origin master to get the remote changes into the local repository, merely without merging them. Then past running git diff main origin/main the Collaborator will run across the changes output in the terminal.

On GitHub, the Collaborator tin go to the repository and click on "commits" to view the most recent commits pushed to the repository.

The Collaborator has some questions about one line change made by the Possessor and has some suggestions to propose.

With GitHub, information technology is possible to comment the diff of a commit. Over the line of code to comment, a blue comment icon appears to open a annotate window.

The Collaborator posts its comments and suggestions using GitHub interface.

Version History, Fill-in, and Version Control

Some fill-in software can keep a history of the versions of your files. They besides allows you to recover specific versions. How is this functionality different from version control? What are some of the benefits of using version control, Git and GitHub?

Fundamental Points

  • git clone copies a remote repository to create a local repository with a remote called origin automatically set up up.

How To Add Collaborator To Github,

Source: https://swcarpentry.github.io/git-novice/08-collab/index.html

Posted by: adamsexperearie.blogspot.com

0 Response to "How To Add Collaborator To Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel