GIT commands that I can't remember

1. When working with shell scripts on Windows if you want to add executable permission to it:

$ git update-index --chmod=+x path/to/file

2. Add remote:

$ git remote add origin ssh://...

3. Revert file to a version from commit:

$ git checkout abcd-hash -- file/to/restore

4. Make a patch. link

$ git format-patch -1 HASH

The -1 flag tells Git how many commits should be included in the patch.

Apply:

$ git am < file.patch

5. Work with stash: https://stackoverflow.com/a/15197232

6. Reset author for last N commits. link

git rebase -i YOUR_SHA -x "git commit --amend --reset-author -CHEAD"

created: 1 Nov 2021
updated: 9 Feb 2023