Skip to content
Zhengyuan Zhu
Go back

Git Usage Memo

Command Quick Reference

Pitfalls to Avoid

Common Errors and Tips

git pull fails with prompt: fatal: refusing to merge unrelated histories

1
2
3
git pull origin master --allow-unrelated-histories
#then
git push origin master

git add to add folder instead of all modified files

1
2
3
4
# Add entire folder and contents
git add yourfile/
# Add all files of this type in directory
git add *.your_file_type

Keep synced with forked repository

1
git remote add your_forked_project_name(whatever you like) https://your_forked_project_url.git
1
git fetch --all
1
git rebase your_forked_project_name/master
1
git push origin master

Handle github not allowing uploads of files larger than 100MB

Remove error cache

1
2
3
4
# for file
git rm --cached path_of_a_giant_file
# for document
git rm --cached -r path_of_a_giant_file

After resubmitting, add large files to Git Large File Storage:

Want to undo to previous commit after git commit

1
git reset --soft HEAD^

git push very slow when writing objects solution

1
git config --global http.postBuffer 524288000

References and copyright notice


Share this post on:

Previous Post
Commonly Used Python Modules
Next Post
Commonly Used Linux Commands
Jack the orange tabby cat
I'm Jack ๐Ÿงก
Luna the tuxedo cat
I'm Luna! ๐Ÿ–ค