Code Monkey home page Code Monkey logo

git-collaboration's Introduction

Git Collaboration 1

Learning Objectives

  • Use git from the command line to stage, commit and push local changes to a remote GitHub repository
  • Explain the purpose of the commands git status and git log.
  • Collaborate with a partner using git and GitHub

Introduction

Git is a tool we use to manage changes in our code projects.

Exercise 1

Decide who's Bob and who's Alice.

Alice, on your computer:

  • Create a new directory called 'introductions'
  • Initialise the directory as a new git repository

Try out git status and see what it says โ€” it's usually useful information. If it says 'Not a git repository' then something is wrong.

Exercise 2

Alice, on your computer:

  • Create a new file called index.html in the directory called 'introductions'

  • Ask your pair partner their name

  • Add the following to it, replacing NAME with their name:

    <h1>Hello NAME!</h1>
  • Stage and commit this change.

Try out git log. You should see your commit there.

Exercise 3

Alice, on your computer:

  • Create a new GitHub repository called 'introductions'
  • Set up your local git repository to point towards the GitHub repository
  • Push your local changes to the Github repository
  • Add your partner as a collaborator on the Github repository

Check out the repository page on Github. You should see your file there.

Exercise 4

Bob, on your computer:

  • Clone (don't fork) your pair partner's 'introductions' repository
  • Open the index.html file in your browser/Live Server to check it works
  • Add a new html element to 'index.html' saying hello back
  • Stage, commit and push your changes

Check back on that repository page โ€” do you see your new changes on Github?

Exercise 5

Bob, on your computer:

  • Open the repository on Github and find the list of commits
  • You should see two commits with your photos
  • You should be able to click the photos and see your Github profile

Here is an example of how it should be:

Exercise 6

Both, on your respective computers:

  • Set up your global git config to use:
    • Your real name
    • The email address you use with GitHub

Here is how you check it is set up correctly:

$ git config --global --get-regexp "user"
user.name edward
user.email [email protected]

Exercise 7

Imagine it is a fresh new day, and you have a new person to pair with: Ada Lovelace.

We want to pick up from where we left off, but without interfering with Alice's repository. To do this, we create a new repository with the same code.

Person on the right, on your computer:

  • Create a new repository on Github called 'introductions-2'
  • Change your local repository remote to point at your new 'introductions-2' repository
  • Write a new introduction to Ada
  • Stage, commit and push your changes

Ada's introduction should now be on Github!

Exercise 8

Using git involves learning a lot of strange commands with weird names.

How can we learn about commands like this? List some techniques:

Getting good at finding out information like this will help you become a better software engineer. Each additional technique you learn might save you days or weeks of time in the long run.

git-collaboration's People

Contributors

dearshrewdwit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.