@savaryna/git-add-account 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +28 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -50,9 +50,36 @@ You will be presented with your public SSH key so you can copy, and add it to yo
50
50
  6. Done! Now you can go to the workspace you chose for the account `/Users/savaryna/code/email` in this example, and all the GIT
51
51
  commands issued from this and children directories will automatically use the correct account.
52
52
 
53
+ ## How it works
54
+
55
+ A simple way to use multiple git accounts on one machine is to use multiple SSH keys configured with different hosts. The way [@savaryna/add-git-account](https://www.npmjs.com/package/@savaryna/git-add-account) works is, it asks you for some basic information and then:
56
+
57
+ 1. It creates a `.gitconfig` file in the workspace directory you specified.
58
+ 2. It creates a SSH keypair using `ssh-keygen -t ed25519 -C "email@you.specified" -f ~/.ssh/git_the_ssh_key_name_you_specified`.
59
+ 3. It appends to the `~/.ssh/config` file.
60
+ ```ini
61
+ # Config for GIT account email@you.specified
62
+ Host *
63
+ AddKeysToAgent yes
64
+ UseKeychain yes
65
+ IdentityFile path/to/the/SSH/key/created/in/step/2
66
+ ```
67
+ 4. It runs `git config --file path/to/.gitconfig/from/step/1 user.name "name_you_specified"` to set your git username.
68
+ 5. It runs `git config --file path/to/.gitconfig/from/step/1 user.email "email@you.specified"` to set your git email.
69
+ 6. It runs `git config --file path/to/.gitconfig/from/step/1 core.sshCommand "ssh -i path/to/the/SSH/key/created/in/step/2"` to make sure all the commands issued from this workspace use the correct SSH key.
70
+ 7. If you chose to sign your work:
71
+ 1. It runs `git config --file path/to/.gitconfig/from/step/1 gpg.format ssh` to use SSH key for signing.
72
+ 2. It runs `git config --file path/to/.gitconfig/from/step/1 commit.gpgsign true` to enable signing commits.
73
+ 3. It runs `git config --file path/to/.gitconfig/from/step/1 push.gpgsign if-asked` to enable signing pushes if supported.
74
+ 4. It runs `git config --file path/to/.gitconfig/from/step/1 tag.gpgsign true` to enable signing tags.
75
+ 5. It runs `git config --file path/to/.gitconfig/from/step/1 user.signingkey path/to/the/SSH/key/created/in/step/2` to set the signing key to the one created in step 2.
76
+ 8. It runs `git config --global includeIf.gitdir:path/to/your/workspace/.path $path/to/.gitconfig/from/step/1`, this makes sure that if you are in the workspace for the created account, git will use the config from step 1 with all the options from the step 5, 6 and 7 automatically.
77
+ 9. And finally it presents you with your public SSH key so you can copy it and add it to your GIT provider of choice.
78
+
79
+
53
80
  ## License
54
81
 
55
- MIT See [LICENSE](LICENSE) file.
82
+ [MIT](LICENSE) © [Alex Tofan](https://github.com/savaryna)
56
83
 
57
84
  [^1]: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account?tool=webui
58
85
  [^2]: https://docs.github.com/en/authentication/managing-commit-signature-verification
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savaryna/git-add-account",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "🔐 A small CLI app that allows you to easily add multiple GIT accounts on one machine. It switches between accounts automatically based on the workspace (directory) you are in.",
5
5
  "homepage": "https://github.com/savaryna/git-add-account#readme",
6
6
  "keywords": [