Jon Dehdari




Git Logo




Git FAQ

Git is a popular software for version control, synchronization, and collaboration. Here are some useful links to help you learn:

How do I undo a commit?

git reset --soft HEAD~
	

How do I spin-off a new repo from an existing one?

git clone old_repo new_repo
cd new_repo
git filter-branch --prune-empty --subdirectory-filter my_subdirectory master
	

How do I push tags upstream?

git push --tags
	
This will push all tags. To push a single tag:
git push origin my_tag
	

How do I add specific lines to a commit?

git add -p
	
This will give you an interactive dialog. Type s to split chunks smaller.

How do I merge a specific commit?

git cherry-pick c2b62e
	

How do I unstage a file that I've already git-added?

git reset <file>
	
To unstage everything that you've git-added:
git reset
	

How do I compare the same file from two different branches ?

Either this way:
git diff branch1 branch2 -- file.txt
	
Or
git diff branch1:path/to/file.txt branch2:path/to/file.txt
	

How do I delete a remote branch?

git push origin --delete mybranch
	

External Links