GithubHelp home page GithubHelp logo

git-basics-lab's Introduction

Git Basics Lab

Learning Goals

  • Understand how to complete labs on Learn
  • Apply what you've learned about Git version control
  • Initialize a new Git repository
  • Stage and commit new content
  • Create a remote repository on GitHub
  • Connect the newly create local repository with the remote on GitHub

Introduction

So far lessons have only contained written content on specific topics. All you needed to do was read through each lesson and continue on. This lesson, however, is considered a lab. Labs are exercises that have some written content to guide you, but also contain tests that must be passed in order to complete the lesson.

Now that you've learned about Git version control, in this lab, we're going to go through the entire process of creating a local Git repository, creating an initial commit and pushing that work to a remote repo stored on GitHub.

NOTE: If you are new to using Learn.co and this is your first lab, welcome! This lesson will include all the steps necessary to submit your lab work to Learn.co.

Getting Started

To start work on this lab, while on Learn.co, click the "Open IDE" button.

If you are using the in-browser Learn IDE, the IDE will open on the page

If you are using the Learn IDE on your computer, the IDE should open automatically

If you are using your own local environment set up, you will need to manually fork and clone this lesson. Click on the GitHub button next to "Open IDE" to visit this lab's repository. Once there, create a personal fork of the repo and clone it down

Once you've got the lesson open, run learn in the command line. Six failed tests should print out, starting with this:

this lab
  1) has a folder named my-repository
  2) has a valid git repository initialized for the my-repository folder
  3) has a README.md file in the my-repository folder

the local repository
  4) has README.md as a tracked file
  5) has at least one commit
  6) has been pushed up to the remote repository


0 passing (42ms)
6 failing

1) this lab
     has a folder named my-repository:
   AssertionError: no folder name "my-repository" was found: value: expected './my-repository' to exist
    at Function.<anonymous> (node_modules/chai-fs/lib/assertions/directory.js:21:53)
    at Function.ctx.(anonymous function) [as directory] (node_modules/chai/lib/chai/utils/addMethod.js:41:25)
    at Function.assert.isDirectory (node_modules/chai-fs/lib/assertions/directory.js:34:35)
    at Context.it (test/index-test.js:11:19)
    ...

Each failed test includes an explanation.

In the first test seen above, for instance, it says this lab has a folder name my-repository, followed by AssertionError: no folder name "my-repository" was found.

This first test is looking specifically for a folder, my-repository, to exist inside this lab' main directory (or "folder"). You probably have a theory on how to correct that test after seeing that error! We're going to use these tests to let us know when we're all done.

Instructions

IMPORTANT TIPS TO AVOID GETTING STUCK

  1. The work you will do to set up the Git repository will be done in the my-repository directory (after you create it ;)). If you're doing git commands in the same directory as THIS README that you're reading right now, you're not going to get to working tests.
  2. When you run the tests, you will need to be in the top-level directory of this lab, (git-basics-lab, the directory with the README you're reading right now in it.)

To get all tests passing in this lab, follow the steps below, applying commands you've learned in the previous lessons.

Steps

As we saw above, there are six broken tests. Let's get them working.

  1. Create a new directory locally named my-repository. This directory should be side by side with the test directory of this lab. Use the Unix command to create this directory. From the top-level of this lab, the parent directory of my-repository, run learn and verify there are only 5 broken tests left.

  2. Navigate into the new directory my-repository using cd on the command line.

  3. While inside my-repository, using the command line, initialize a new git repository. You'll know you've done it if you see 'Initialized empty Git repository in <...your local directory>/my-repository/.git/'>. Change back-up to the parent directory and you should be back in the top-level directory. Run learn and you should be down to four tests left. If that's true, change back into my-repository.

  4. Create a file called README.md inside my-repository.

  5. If you run git status at the command line, you should see that README.md is now listed as an untracked file. Add README.md so that it is tracked by Git.

  6. Once the file is tracked, running git status again will show that README.md is staged and ready to be committed. Go ahead and create a commit on the command line (don't forget to add -m when committing to include a message!)

    NOTE: If you forget to include -m on when committing, you'll find you've opened vi, the built in terminal text editor. To escape out of this editor, press the 'esc' key once, then type :q! to close the editor and return to the normal terminal.

  7. Change back to the top-level directory, run learn, and you'll see that the test output is looking pretty successful:

  this lab
    ✓ has a folder named my-repository
    ✓ has a valid git repository initialized for the my-repository folder
    ✓ has a README.md file in the my-repository folder

  the local repository
    ✓ has README.md as a tracked file
    ✓ has at least one commit
    1) has been pushed up to the remote repository


  5 passing (18ms)
  1 failing

  1) the local repository
       has been pushed up to the remote repository:
     AssertionError: no record of pushing to a remote was found. Follow the instructions on GitHub to connect and push to a new remote repository: value: expected './my-repository/.git/logs/refs/remotes' to exist

Almost done! Change back into the my-repository directory.

  1. Create a remote repository on GitHub using your personal GitHub account. When we create a blank repository, we are given instructions for adding that repository as a remote. Copy the first line (git remote add origin...) and paste-and-run it from your command line to connect your local repository with the new remote one.

  2. Still within the my-repository directory, push up your local work to the remote.

  3. Change back up to the top-level directory and run learn once more, your tests should all be passing

If all tests are passing, when you run learn, Learn.co will be notified and register that you've passed the tests. Once you've passed all tests, run learn submit to register completion of this lab on Learn.co.

Conclusion

As you become more comfortable with the terminal and Git, you'll find yourself using the workflow of initializing, adding, committing and pushing your work on a regular basis. These commands are at the core of Git version control. By knowing them, you now have the ability to create your own repositories and contribute to repositories that already exist.

In this lab you used tests to guide you in the basics of setting up a new local Git repository and binding it to a remote repository on GitHub. By pushing your work to a remote repository you've backed it up and made it available for the world to see via GitHub. Professional developers use this process to share code with each other, to document their code, and to earn interview slots by showing off what they're capable of. You did this guided by tests. It's common for developers to write tasks as tests that all fail and then slowly work to get them all passing. It's like a to-do list that verifies you've actually done the work!

git-basics-lab's People

Contributors

annjohn avatar dependabot[bot] avatar drakeltheryuujin avatar febbraiod avatar gj avatar jenmyers avatar jmburges avatar joshuabamboo avatar lizbur10 avatar louiefigz avatar maxwellbenton avatar plai217 avatar pletcher avatar preetness avatar sgharms avatar

Watchers

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

git-basics-lab's Issues

IDE seems not to be working

My connection keeps cutting out and it isn't allowing me to cd back to the original file location to test my lab.

Git push prompts for your password

When trying to push my changes to my remote branch I am prompted to sign in to GitHub and when I logged in using my credentials I get an unauthorized error and my lab is still failing with one error that my changes have not been pushed.

command: git-basics-lab-v-000>git push origin master
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': sequina
Password for 'https://[email protected]':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/sequina/git-basics-lab-v-000.git/'

git-basics-lab

this is bin happening for past 5 hours

(There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.)

Git and Flatiron

I haven't found clear instructions on how to have my own IDE record lab progress throughout this course. I can fork and clone, but the learn site doesn't show that it happened. And, obviously, my terminal isn't able to recognize the learn command. Is this functionality not possible?

Tests won't run in IDE (in-browser or desktop)

Running learn in both the in-browser and desktop IDE results in the following error message:

/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha/lib/reporters/base.js:300
  runner.stats = stats;
               ^

TypeError: Cannot set property stats of #<EventEmitter> which has only a getter
    at Spec.Base (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha/lib/reporters/base.js:300:16)
    at new Spec (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha/lib/reporters/spec.js:30:8)
    at withReplacedStdout (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:220:21)
    at withReplacedStdout (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:146:12)
    at setup.map (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:216:14)
    at Array.map (<anonymous>)
    at initReportersAndStreams (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:208:6)
    at mochaMulti (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:267:31)
    at new MochaMulti (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha-multi/mocha-multi.js:293:25)
    at Mocha.run (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha/lib/mocha.js:582:18)
    at Object.<anonymous> (/home/bionic-template-4026/git-basics-lab-online-web-sp-000/node_modules/mocha/bin/_mocha:637:18)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
[18:44:08] ((HEAD detached at 7114f63)) git-basics-lab-online-web-sp-000
// ♥ Traceback (most recent call last):
        11: from /usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in&#96;<main>'
        10: from /usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in&#96;eval'
         9: from /usr/local/rvm/gems/ruby-2.6.1/bin/learn-test:23:in &#96;<main>'
         8: from /usr/local/rvm/gems/ruby-2.6.1/bin/learn-test:23:in &#96;load'
         7: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/bin/learn-test:68:in &#96;<top (required)>'
         6: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:20:in &#96;run'
         5: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:20:in &#96;fork'
         4: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:21:in &#96;block in run'
         3: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/runner.rb:44:in &#96;report_and_clean'
         2: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/reporter.rb:13:in &#96;report'
         1: from /usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/reporter.rb:47:in &#96;report'
/usr/local/rvm/gems/ruby-2.6.1/gems/learn-test-2.6.1/lib/learn_test/strategies/mocha.rb:42:in &#96;results': undefined method &#96;[]' for nil:NilClass (NoMethodError)

I was able to reproduce this with @BlythePollard.

git and learn not syncing

I added a folder and readme.md file within my project on the in browser learn ide. I can use the ls command to see the folders, but they weren't showing up in the browser. After running learn, that test passed and now the folder shows, but there are other errors now that I am not sure are with the syncing or how I input the commands. This is frustrating as I feel like I completed it correctly, yet my tests are failing. I don't know if I'm wrong, or if learn is just having issues.

Lab design leads often leads to git issues, especially for IDE users

I have worked with many students that get lost trying to debug github issues due to running git commands in the wrong directory in the IDE (in the parent directory rather than in the my-repository directory they have created).

This often leads to them spending a very long time on this lab trying to debug complex git issues, which detracts from what they should have learned from this lesson.

I think removing the instruction to switch back and forth between the parent directory and my-repository to run the tests after every step and being more explicit about where each commend should be run should help quite a bit.

LearnIDE not letting me write my password

Every time I try to push the local repository to a remote one I created on Github the learnIDE doesn't allow me to write the password of my account, I tried this several times and end up getting stuck all over again.

issue with lab

i think there's an issue with the test(s) for this lab; i'm passing all six tests but running into errors when i run learn test, getting the following message on the last check in the index-test.js file (even when creating a final test that just returns true):

.rvm/gems/ruby-2.4.1/gems/learn-test-2.5.6/lib/learn_test/strategies/mocha.rb:45:in results': undefined method []' for nil:NilClass (NoMethodError)

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.