stephen-makrogianni
3/4/2018 - 10:23 PM

Git

To delete a local branch:

git branch -d the_local_branch

To remove a remote branch (if you know what you are doing!):

git push origin :the_remote_branch

or simply use the new syntax (v1.7.0):

git push origin --delete the_remote_branch

Remove all local branches

git branch | grep -v "master" | xargs git branch -D

Helpful links

https://dangitgit.com/?ref=devawesome.io

How to remove local untracked files from the current Git branch

For reference: https://koukia.ca/how-to-remove-local-untracked-files-from-the-current-git-branch-571c6ce9b6b1

See which files will be delete

git clean -n

Will delete the files

git clean -f

Clear git cache

git rm -r --cached .

Git ignore changes to already tracked files

Where file is the name of the file you want to ignore
git update-index --assume-unchanged <file>

Opposite to above

git update-index --no-assume-unchanged <file>

Look at the git config

git config --global -l

Set windows line-endings and update all line-ending

https://gist.github.com/ajdruff/16427061a41ca8c08c05992a6c74f59e

Essentially:

Set LF as your line ending default.

git config --global core.eol lf

Remove the index and force Git to rescan the working directory.

rm .git/index

Rewrite the Git index to pick up all the new line endings.

git reset

Errors

Error: Your github oauth token for github.com contains invalid characters

Fix:

Fix reference: https://nono.ma/github-oauth-token-for-github-com-contains-invalid-characters-on-composer-install