Skip to content

Latest commit

 

History

History
63 lines (56 loc) · 3.48 KB

File metadata and controls

63 lines (56 loc) · 3.48 KB

Learn Git

"Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible.- from: OShitGit"

Basic Git Commands (see Git Cheatsheet)

Common git commands in day-to-day workflow

  1. Set up the origin folder (on local computer) and watch the files.
  2. Compare changes diff command and commit to github.

CREATE REPO: (Start new repository/Obtain one from an existing URL)

  • $ git init(Create an empty git repo/reinitialize an existing one)
  • $ git init [project-name] (Create new local repository with specified name)
  • $ git clone [url] (Downloads project and entire version history)

FORK A REPO

Click the "Fork" button at the top-right of any repository's GitHub page.

CLONE A REPO

  • $ git clone https://github.com/<username>/foo.git foo(Clone a repo into a new directory called foo):

SETUP REMOTES:

  • $ git remote -v (see list of repositories (remotes) whose branches you track)

MAKE CHANGES: (Review edits and craf a commit transaction)

  • $ git status (Lists all new/modified files to be commited)
  • $ git add [file] (Snapshots file in preparation for versioning)
  • $ git reset [file](Unstages file, preserve its contents)
  • $ git diff(Shows file differences, not yet staged)
  • $ git diff --staged(Shows file differences, between staging - last file version)
  • $ git commit -m "[descriptive message]"(Records file snapshots permanently in version history)

TROUBLE SHOOTING

  • git reflog(list all git steps (index HEAD@{index})

  • git reset HEAD@{index} (find last git step before it breaks)

  • git add . # or add individual files (make change)

  • git commit --amend (change or keep commit.The last commit contains change)

  • git branch some-new-branch-name(create new branch from current state/master)

  • git reset HEAD~ --hard (remove commit from master branch)

  • git checkout some-new-branch-name (commit lives in branch)

  • git checkout name-of-the-correct-branch/- git cherry-pick master (grab last commit to master)

  • git checkout master OR git reset HEAD~ --hard (delete from master)

  • git diff --staged (Git won't do a diff of files add to staging area without this flag.)

  • npm install

  • npm start

  • ls= lists directories & files inside a folder. in chrome put http://localhost:3000

  • npm run build= create production build

  • cd stands for change directory ex: cd src find within this path a src directory and move inside of it

  • ./ = same directory where file which is importing resides ex: go to ./ directory and find me X.js file

  • git checkout -b development =move into/create development branch

  • git checkout master= merge to master

Resources