How to setup repository in GIT in local machine and connect to Github (Mac M5 Air)
Check if git is installed in your machine
Wiki topics:
🔓 · Open Source

How to setup repository in GIT in local machine and connect to Github (Mac M5 Air)
Check if git is installed in your machine
> git --version
It should return a version
git version 2.50.1 (Apple Git-155)
If it isn’t, a popup will appear asking you to install Xcode Command Line Tools. Click Install and accept the terms. macOS will download and install Git automatically.
Login to terminal
git config --global user.name "Your Name"
git config --global user.email "yourname@example.com"
Notes:
- “ — global” means the same config would be used in every git repo in the machine
To set default branch name, run the below command
git config --global init.defaultBranch <branch_name> # eg. main or master
To ensure everything saved correctly, run:
command : git config --list
Result :
credential.helper=osxkeychain
init.defaultbranch=main
user.name="Your Name"
user.email="yourname@example.com"
init.defaultbranch="branch_name"
Create a SSH Key
- Create a SSH key to connect with Github
ssh-keygen -t ed25519 -C "your.email@example.com" Press enter until the key is generated- View the SSH key
cat ~/.ssh/id_ed25519.pub- Copy the SSH key
pbcopy < ~/.ssh/id_ed25519.pub
Login to Github and initialise project
- Go to **GitHub.com** and log in.
- Click your profile picture (top right) → Settings.
- In the left sidebar, click SSH and GPG keys.
- Click the green New SSH key button.
- Give it a title (like “My Mac”) and paste the key into the Key box. Click Add SSH key.
Initialise GIT in project
Navigate to the folder
cd /path_to_the_folder
- Initialise git in the folder
git init- All all files to git
git add .- Add initial commit
git commit -m "Initial commit"
Connect local repo to github
git remote add origin git@github.com:RakeshM7/dsa-interview-prep.git
git branch -M main
git push -u origin main
Happy coding and collaborating!
메타데이터
- post_id
- da8dc337a8ce
- slug
- setting-up-git-in-local-machine-mac-m5-air-da8dc337a8ce
- url
- https://medium.com/@akashmrakesh/setting-up-git-in-local-machine-mac-m5-air-da8dc337a8ce
- canonical_url
- https://medium.com/@akashmrakesh/setting-up-git-in-local-machine-mac-m5-air-da8dc337a8ce
- author_url
- https://medium.com/@akashmrakesh
- status
- ok
- fetched_at
- 2026-06-12 07:40:50