Giter Club home page Giter Club logo

phase-0-getting-code-with-git's Introduction

Getting Code with Git

Learning Goals

  • Copy a repository to your local machine with git clone
  • List remotes with git remote
  • Duplicate other organizations' repositories into your own via GitHub with the "Fork" button

Introduction

In the previous lesson, we learned how Git allows us to create logged histories of all the versions of the files we "track." Another great benefit of using Git is that it makes it easy for developers to "share" code by "pushing" a copy of their repo to the internet (specifically, to GitHub). From there, other developers can clone down the code onto their own machine and use it.

Of course, you've been taking advantage of this feature of Git for a while with the labs you've been working on in this course! For this reason, a lot of the content in this lesson will be review.

The important thing to understand is that the forking and cloning workflow that you've been using with labs can be used with any repo available on GitHub.

Copy a Repository to Your Local Machine with git clone

Let's review the cloning process using a repo that isn't part of the curriculum. We can get the code for the popular ReactJS framework:

  1. Navigate to the React repository.

  2. Click the green "Code" button on the right.

  3. Make sure SSH is selected.

  4. Click the copy button.

clone-repo

  1. In the terminal, navigate to where you want to put the repo. Type git clone and a space, then paste in the copied SSH link from GitHub. It should look like this:
$ git clone [email protected]:facebook/react.git

This will create a local copy of the GitHub repository on your machine.

List Remote Repos with git remote

If you use the ls command, you'll see Git created a directory called react. Use cd to enter that directory.

$ cd react

The git remote command will return the names of each remote repository (or, "remote") available. Go ahead and run the command; you should see a remote named origin returned. This is the "nickname" that Git assigns by default to whatever remote you cloned from:

$ git remote
origin

To prove that the origin name points to the repo we cloned from GitHub, we can run git remote -v (the v flag stands for "verbose"). You should see something like this:

$  git remote -v
origin	[email protected]:facebook/react.git (fetch)
origin	[email protected]:facebook/react.git (push)

Here you can see that the "remote address" ([email protected]:facebook/react.git) assigned to the "remote name" (origin) is the same thing you copied from the GitHub web interface. This confirms that the remote repository you cloned automatically set up a remote name called origin.

In the next lesson we'll learn how to push code up to GitHub. The git remote command is what will enable you to ensure that the code is being pushed to the right place.

Duplicate Other Organizations' Repositories into Your Own via GitHub with the "Fork" Button

This is also part of the workflow you've been using for labs: you create your own personal copy of a lab by clicking the "OctoCat" icon on Canvas, then the "Fork" button on GitHub.

Let's go back to the React repository on GitHub. In the upper right corner of the page, you'll see three buttons, including the familiar Fork button:

Fork Button

Clicking the Fork button on the page for this repo (or any other repo available on GitHub) will make a copy of the repo and store it in your GitHub account. Having your own copy gives you the ability to update its main (or master) branch without affecting the original repo.

Conclusion

GitHub gives developers many ways to collaborate. Using GitHub's "Fork" button and git clone together allows you to make copies of others' code.

Often, the original authors will include license information regarding how you can use their repository, so make sure to check before you publish, sell or distribute any material you've forked, cloned and modified.

phase-0-getting-code-with-git's People

Contributors

drakeltheryuujin avatar ihollander avatar jenmyers avatar jlboba avatar lizbur10 avatar marcnjaramillo avatar maxwellbenton avatar meg-gutshall avatar rrcobb avatar sgharms avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phase-0-getting-code-with-git's Issues

Incorrect Repository Source Link in Canvas Lesson

Canvas Link

https://learning.flatironschool.com/courses/7201/pages/getting-code-with-git?module_item_id=606356

Concern

The incorrect link is found in the section for Git in the lesson Getting Code with Git. The incorrect link when clicking on the GitHub Logo is:

https://github.com/learn-co-curriculum/phase-0-getting-code-with

the corrected URL should be:

https://github.com/learn-co-curriculum/phase-0-getting-code-with-git

Additional Context

The straightforward nature of this fix requires a simple update in the Canvas lesson's hyperlink, yet its implementation is crucial for us learners.

Suggested Changes

Please update the Canvas lesson to replace the incorrect link with the correct link to ensure a seamless learning experience for the learners. The bad link lacks the '-git' suffix, leading to a 404 error page instead of the intended repository. I clicked it and found a 404 which is how it was discovered.

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.