"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
- Set up the origin folder (on local computer) and watch the files.
- Compare changes
diffcommand and commit to github.
$ 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)
Click the "Fork" button at the top-right of any repository's GitHub page.
$ git clone https://github.com/<username>/foo.git foo(Clone a repo into a new directory called foo):
$ git remote -v(see list of repositories (remotes) whose branches you track)
$ 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)
-
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 masterORgit 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 -
cdstands for change directory ex:cd srcfind 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 meX.jsfile -
git checkout -b development=move into/create development branch -
git checkout master= merge to master