9/11/2017 - 10:28 PM



git init # go inside a folder and use this to make it a git repo
git status #difference between work dir,staging index and local repo 
           # note doesnt care about remote repo
git config --global user.name pallav

git help #gives you options for help
git add –A  (to add all files in your local repository) 

git add <filename> (to add a single file)

#Commit files that are being tracked 
git commit –m –a (to commit all files)

git commit –m <filename> #(to commit a single file)

#Finally push to the global repository
git push origin master

#In the morning, pull all the files from the global repository
git pull origin master

#to pull and update and push
git pull origin master && git status && git add -A && git commit -ma && git push origin master

A branch essentially says "I want to include the work of this commit and all parent commits."
git branch newbranch1
git checkout newbranch1 #switches to the newbranch1

Merging in Git creates a special commit that has two unique parents. A commit with two parents essentially means "I want to include all the work from this parent over here and this one over here, and the set of all their parents."
git merge branchtobemerged1
git pull is git fetch + git merge whateverbranchwas fetched1 

git rebase master #rebasing on master #master wil be base

HEAD is just a pointer which points to tip on the current branch in the "repository"
"HEAD". HEAD is the symbolic name for the currently checked out commit -- it's essentially what commit you're working on top of.
Easy! We can travel backwards in time with HEAD^
git checkout HEAD^

git branch -f master HEAD~3 #Moves (by force) the master branch to three parents behind HEAD


if you look at a branch named o/master, the branch name is master and the name of the remote is o.

git log --author="Homa" #all commits by homa # need only part of the name
git log --grep="Init" # searches for commits which have init in it 
git log --stat Tasks.docx #log with statistics

git diff # compares files in the local repo and working directory
git diff file1.txt #just compares these two files b/w LR and WD

####when deleting you have to go through the same steps add n commit

git checkout sth1 #just clones sth1 from LR TO WD #discard WD changes
git checkout -- text1.txt # -- means stay on this branch and clone text1.txt

git reset HEAD text1.txt #used to unstage text1.txt if accidentally staged
                         #resets the index to the HEAD
git checkout 272asuuasg -- text1.txt #revert text1.txt to this commit index

git diff branch1..branch2 #comapring between two branches

we said that remote branches reflect the state of the remote repositories since you last talked to those remotes. git fetch is the way you talk to these remotes 

git reset --hard 0d1d7fc32