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
- Add forked project to remote
1
git remote add your_forked_project_name(whatever you like) https://your_forked_project_url.git
- Update all remote repos in remote
1
git fetch --all
- Perform synchronization
1
git rebase your_forked_project_name/master
- Sync your own remote repository
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:
-
Install git-lfs:
brew install git-lfs -
Initialize in repository root directory:
git lfs install -
Track large file name:
git lfs track "name_of_your_giant_file_not_your_path!" -
Commit and push normally:
git add your_giant_file_path -
Search for large files:
find ./ -size +100M
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