Skip to content

Instantly share code, notes, and snippets.

@tbierwirth
Last active April 14, 2019 21:43
Show Gist options
  • Save tbierwirth/25a8b60ad9a648519e5931e4ffb864b1 to your computer and use it in GitHub Desktop.
Save tbierwirth/25a8b60ad9a648519e5931e4ffb864b1 to your computer and use it in GitHub Desktop.

github

Git Terminal Commands

  • git init
    • Creates an empty Git repository or reinitializes an existing one.
  • git add
    • Adds a file to the staging area to prepare it for a commit.
  • git commit
    • Create a new commit and records changes into the repository.
  • git push
    • Push changes made to the remote master branch of a repository.
  • git pull
    • Pull any changes made from the remote master branch to the local machine.
  • git status
    • Displays the state of the working directory and the staging area.

Example Workflow

  1. Open a terminal and create project folder on local machine and cd into it
    • mkdir Example_Project
    • cd Example_Project
  2. Initialize the folder and add initial commit
    • git init
    • git commit -m 'Initial commit'
  3. Create an example ruby program and add some code with your text editor
    • touch example.rb
    • puts "Here is some example code"
  4. Add example.rb to the staging area
    • git add example.rb
  5. Commit changes and check status of working directory
    • git commit -m 'Add code to example.rb'
    • git status
  6. Push changes to the remote master branch
    • git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment