Skip to content

Latest commit

 

History

History
161 lines (95 loc) · 5.86 KB

02 - Creating my first repository.md

File metadata and controls

161 lines (95 loc) · 5.86 KB

What is a repository?

A Git repository or repo is a virtual storage of your project. It allows you to save versions of your code, which you can access when needed.

Creating a repository

  1. Log in to your GitHub account.

  2. Click the + button on the upper right corner of the page and select New repository.

  3. Name your repository my-first-repo and check Initialize this repository with a README.

  4. Click Create repository.

repo-create

Mabuhay! You now have a new repository named my-first-repo with a README markdown file.

repo-new

Cloning a repository

Now that you have a remote repository on GitHub, it's time to get a local copy on your computer.

Cloning is the most common way for users to obtain a local copy of a remote repository with existing files.

If you're working with an empty repository, you need to initialize it using git init to get a local copy. For more information, you can check out this interactive tutorial by Code School and GitHub.

  1. Go to the repo that you created on GitHub and click on the green Clone or download button.

repo-clone

  1. Copy the HTTPS link by clicking the copy button or selecting the link and pressing CTRL + C.

  2. Open your console and go to the path where you want to place the local copy of your repository.

$ cd <path-to-directory>

Bonus: If you're using bash, type pwd to get the present working directory. If you're using cmd, type cd instead.

  1. Clone the repository using git clone.
$ git clone <repository-https-link>

Ta-da! You can now check the directory where you placed your local copy. You should see a folder with named my-first-repo with the README file inside.

Editing files

Before you start editing, make sure you're familiar with the following terms:

  • text editor
  • markdown
  • README

Text editors

A text editor is any word processing program that you can use to type and edit text.

Commonly used text editors:

Markdown

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists. Mostly, markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.

This file is also created using markdown, thus the .md file extension!

README

You can add a README file to your repository to tell other people why your project is useful, what they can do with your project, and how they can use it.

A README file, along with a repository license, contribution guidelines, and a code of conduct, helps you communicate expectations for and manage contributions to your project.

A README is often the first item a visitor will see when visiting your repository. README files typically include information on:

  • What the project does
  • Why the project is useful
  • How users can get started with the project
  • Where users can get help with your project
  • Who maintains and contributes to the project

If you put your README file in your repository's root, docs, or hidden .github directory, GitHub will recognize and automatically surface your README to repository visitors.

Here's an example of a good README template.

Activity!

  1. Open the README file inside my-first-repo using your favorite text editor, preferably one that allows markdown preview.

  2. Add the following text below "# my-first-repo":

This is a sample repository.

# Authors

* [Alysson Alvaran](https://github.com/alyssonalvaran)

Note: # translates to the HTML <h1> tag, ## translates to <h2>, and so on. * translates to a bullet and [text](link) allows you to insert a hyperlink to a text.

If you don't have a markdown preview feature on your text editor, you can paste your codes here to see what it looks like.

Pushing changes

Now that you're done editing, our final step is to push to changes back to the remote repository.

Pushing uploads your local commits to your remote repository.

  1. Open your console and check the unstages changes that you made.
$ git status
  1. Add the file to be committed using git add <filename>.
$ git add README.md

You may also use git add --all to add all of the unstaged and untracked files if you're working on multiple files at a time.

  1. Commit the staged changes to your local repository using git commit -m <commit-message>.
$ git commit -m "Initial commit"

Bonus: You can use git log to display the list of commits that you've made so far.

  1. Finally, push your commit to the remote repository using git push <remote> <branch>.
git push origin main

origin is the default remote created by GitHub that corresponds to the URL of your repository while main is the default branch. You'll learn more about these in the next lessons.

Congratulations!

You've successfully created and pushed your changes to your first repository!

Didn't quite Git it?

Feel free to ask and participate in our Gitter chat room!

References