UNB/ CS/ David Bremner/ teaching/ cs2613/ labs/ L03/ before

Reading

Git Practice: Working with multiple git repos

Time
15-30 minutes
Activity
Individual work, outside scheduled lab time.

Cloning

  1. Open a terminal.

  2. Make a directory lab2-scratch somewhere outside the cs2613 git repository you created earlier.

  3. Now move to the lab2-scratch directory, and make a clone of the central repo.

     $ git clone -b main https://$username@vcs.cs.unb.ca/git/cs2613-$username cs2613-clone
    

    This creates a new directory "cs2613-clone" containing a clone of your repository. Notice that in general this is a good way of checking that your work is properly submitted. The TA and Prof will do exactly this cloning step in order to mark your work. The clone is on an equal footing with the original project, possessing its own copy of the original project’s history.

Sharing changes with a central repo

Optional, but useful if you plan to run git on your own computer

  1. Open a terminal

  2. Navigate to the ~/lab2-scratch/cs2613-clone/journal directory.

  3. create a new blog entry, and commit it.

  4. Push your changes back to the central repository.

     $ git push origin main
    
  5. Change directory to your original directory ~/cs2613. Bring in the changes you made

     $ git pull origin main
    

This merges the changes from the central copy of "main" branch into the current branch. If you made other changes in the meantime, then you may need to manually fix any conflicts.

The "pull" command thus performs two operations: it fetches changes from a remote branch, then merges them into the current branch.

Questions

Here are some questions we will be discussing at the beginning of L03.

Git next steps

Congratulations, you now know enough git to finish this course.

There is lots more to learn, particularly about branching and collaboration. If you want to get a big(ger) picture view, a good place to start is Git Concepts Simplified.