Koren Leslie Cohen

  • About
  • Blog
  • Contact

0 comments

Git, GitHub

Basic Git Cheat Sheet

May 30, 2014 by Koren Leslie Cohen

setup git

Git allows us to keep track of the changes in our code, and to store those changes.  This is known as version control.  When used with GitHub, git allows us to keep track of our code in publicly accessible repositories.

Git

$ git init   Initializes new repository

$ git  add .   Adds the current directory to git.  This automatically includes all subdirectories.  You can accomplish the same task with $ git add filename.  When you run this command, your files are added to the staging area.

$ git status   Tells you which files are in the staging area.

$ git commit -m “initial commit”   Tells git you want to commit, or keep, your changes.  You can put any message you like inside the quotation marks.  Note: Git commits are local to your machine.  Committing to Git is not the same as pushing to GitHub.

$ git log   Shows you a list of your commit messages.

Pushing to GitHub

To push your commit to GitHub, you need to create a repository for your project, or push to an existing repository.  Once your repository is created, you should see several helpful commands and links in the repository.  In existing repositories, the link you need will be in the right sidebar.  These will be helpful in pushing your content from git to GitHub.

$ git remote add origin https://<link in repository>  followed by $ git push -u origin master.  This pushes your code to the chosen repository.

You should now see your code in your GitHub repository.

  • About
  • Latest Posts
Connect
Koren Leslie Cohen
Product manager at Facebook. Former senior product manager at Dollar Shave Club in Los Angeles and software engineer at J.Crew / Madewell in New York City. Recovering trial lawyer.
Connect
Latest posts by Koren Leslie Cohen (see all)
  • PM Career Story - April 28, 2022
  • How to Transition into Product Management - December 26, 2017
  • What I’ve Learned in My First Few Months as a Product Manager - October 14, 2015

Related Posts

Git Branching

Share

Facebook Google+ Twitter Pinterest Email

Comments Cancel reply

Your email address will not be published. Required fields are marked *

*

code

Back to Blog

  • GitHub
  • Instagram
  • LinkedIn
  • RSS
  • Twitter

Looking for something?

Copyright 2023 Koren Leslie Cohen