Code Monkey home page Code Monkey logo

git-essentials-livelessons's Introduction

Git Commands

Git Notes

Git notes for local work

  • git init: initialize current folder as a git repository

  • git clone <url>: brings the git repo from <url> to the current folder

  • git status: tells us what we need to know about our repository

  • git add <FILE>: adds <FILE> to the stagin area

  • git commit: open a text editor to write commit message

    • git commit -m "MESSAGE": writes MESSAGE as a commit without a text editor
  • git log: shows the log (history) of our commits

    • git log --oneline: shows the shorter oneline log (history) of our commits
  • git diff: compare current uncommitted state with the last known git state

    • git diff --staged: runs git diff between the staging aread and the last known state
  • git diff <HEAD~<NUMBER>: compares HEAD with commit <NUMBER> ago (relative)

  • git diff <HASH>: compares HEAD with the commit in <HASH>

  • git restore --source <HASH or HEAD~> <FILE>: restore FILE to <HASH or HEAD~>

  • git checkout <HASH or HEAD~> <FILE>: restore FILE to <HASH or HEAD~>

    • git checkout <HASH or HEAD~>: if you forget file, you end up in detached HEAD state
    • git checkout main: go back to main
    • git switch -: go back to main

Git notes for working with remotes

  • git remote add <NAME> <URL>: adds the <URL> as a remote with the name <NAME>
    • <NAME> is by convention called origin
  • git remote rm <NAME>: removes the remote calles <NAME>
  • git remote -v: look at all the remotes you have
  • git push <WHERE> <WHAT>: pushes the <WHAT> branch to <WHERE>
  • git pull <WHERE> <WHAT>: pulls the <WHAT> branch in <WHERE> to the local computer

git-essentials-livelessons's People

Contributors

mreddycap avatar

Watchers

 avatar

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.