Git Help

I accidentally made a commit before switching off the master branch.

git reset --hard HEAD^

I made commits to master but did not push

git checkout existingbranch
git merge master # Bring the commits here
git checkout master
git reset --keep HEAD~3 # Move master back by 3 commits.
git checkout existingbranch

I checked a (large data) file into the repo and now I can't push to github

#for folders:
git filter-branch --tree-filter 'rm -rf path/path' HEAD
#for files:
git filter-branch --tree-filter 'rm file' HEAD

Push a bunch of small commits together (squash)

git push force #if you have already pushed commits

If you are working with github and using non-"Master" branches for development, you can squash the commits before merging through the website gui., but i haven't tried it.

Accidentally merged the wrong pull request/commit

git reset --merge <COMMIT HASH>

Reset a file and lose all progress

git checkout -- filename

Pushed big changes to a repo. Now i want to reset my local repo to match master