My Git Notes

Typical git commands

git clone<user_name>/the-repo-you-are-cloning.git git fetch upstream git merge upstream/master git add <file> git status and git diff git status -s git commit -m 'the message goes here for the commit' git add '*.<file_extension>' git rm --cached <file> git log git log --summary git reset <file> git rebase

Work with branches

git branch -r git remote <name> origin git push origin --delete <branchName> git checkout <target>

Work with Git Remote URL (URI)

git remote add origin<username>/<reponame>.git git remote set-url origin<username>/<reponame>.git git remote -v

Force git to overwrite local files on pull

git fetch --all<br>git reset --hard origin/master

1. downloads the latest from remote without trying to merge or rebase anything.

2. resets the master branch to what you just fetched

Tag version

Create tag

Delete tag, also remote

Set commit messages in modal text editor, like Vim

Fork & Merge changes from remote Github repository to your local repository

git clone <Your Public Clone URL>

	cd <Local-Repository>
	git remote add <remote-name> <Public Clone URL>
	git fetch <remote-name>


	git remote add <name> <Public Clone URL>
	git pull <name> master
	git push


	$ git clone
	cd wp-butler
	git remote add upstream git://
	git fetch upstream
	git pull upstream master
	git push

Rollback a git repository to a specific commit

git reset --hard <old-commit-id>> git push -f <remote-name> <branch-name>

How to undo a local/public commit

git revert HEAD git reset --soft HEAD^

More, check out (StackOverflow 927358)[]

Clean up a fork and restart it from the upstream

Using 'upstream' as the remote name referencing the original repo forked

More, check out (StackOverflow 9646167)[]

Submodule git commands

git submodule init git submodule update --recursive

Helpful .gitconfig Configurations

		a = !"git alias"
		c = commit
		s = status
		p = pull
		w = whatchanged
		rb = rebase
		# Rebase interactive
		rbi = !"git rebase -i"
		# Rebase interactive on our unpushed commits
		rbiu = !"git rebase -i @{u}"