MariaSzubski
9/28/2017 - 8:44 PM

Useful git commands

Useful git commands

log/diff --stat
	# diagram of changes per file

log/diff --shortstat
	# count of changes

log --oneline
	# sha + commit messages
	
shortlog
	# commit messages
  
shortlog -s
	# commit count per author
	

branch <branch-name>
	# create new branch

checkout -b <branch-name>
	# create new branch and move to it

fork
	# Create your own copy of a repo
	# push changes to your fork before creating a pull request
	
clone
	# Pull repo to new directory (or remote -> local)

fetch
	# get latest changes from origin, don't merge
	
fetch upstream
  # sync with upstream repo

checkout master
  # ready to sync
  
merge upstream/master
  # merge upstream repo into local files
  
rebase master
  # if upstream adds new commits
	
git pull
	# fetch  + merge
	
git push
	# push changes to origin
	
git push -u origin <branch_name>
	# link local branch to existing repository

git remote
	# add connection to original repository to pull down changes
	


reset
	# unstage, keep changes

reset --hard
	# back to last commit
	
reset --hard origin/master
	# reset to remote repository

------
To merge branches:
  
git checkout <branch>
git merge master

git checkout master
git merge <branch>

------
To Upload:

git push gdi master