Setup git with github on macos

2 min read

you can install git on macos using homebrew by running this command:

brew install git

you can check the version using:

git -v

now add your git credentials on the .gitconfig file, you can open that file on your code editor code .gitconfig, like this:

[user]
    name = your name
    email = your email
[init]
    defaultBranch = main
[credential]
    helper = osxkeychain

next thing to do is to generate a new github token so that we can push / pull our code to / from github, go to:

  • settings -> developer settings -> personal access token -> tokens (classic) -> generate new token (classic)
  • then you can select all of the checkboxes and copy your generated token

now you'll have to add your credentials into keychain access, or remove existing ones for github if they already exists. you can run the following commands to delete:

git credential-osxkeychain erase
host=github.com
protocol=https

to add, we can either add it from the keychain access app itself or while cloning or pushing to any existing repository. while doing so, you'll be promted to add your github username and passoword.

so for username, you can add your github username and for passoword add your token that you had generated before.

and voila, it's done!

If you found this article helpful, I would be grateful for your support.
"Buy me some paneer curry"

Comments

I'd love to read your thoughts on this article!!!