|
1 | | -🚀 GitHub SSH Guide: Upload and Download Files |
| 1 | +# GitHub SSH Guide: Upload and Download Files |
2 | 2 |
|
3 | 3 | This guide shows you how to: |
4 | 4 |
|
5 | | -✅ Set up SSH with GitHub |
6 | | - |
7 | | -🧾 Set your Git name and email |
8 | | - |
9 | | -⬆️ Upload (push) files to GitHub |
10 | | - |
11 | | -⬇️ Download (clone) files from GitHub |
12 | | - |
13 | | - |
| 5 | +* ✅ Set up SSH with GitHub |
| 6 | +* ✍️ Set your Git name and email |
| 7 | +* ⬆️ Upload (push) files to GitHub |
| 8 | +* ⬇️ Download (clone) files from GitHub |
14 | 9 |
|
15 | 10 | --- |
16 | 11 |
|
17 | | -🛠️ 1. Set Up SSH (Do Once) |
| 12 | +## 🛠️ 1. Set Up SSH (Do Once) |
18 | 13 |
|
19 | | -🔐 1.1 – Make a New SSH Key |
| 14 | +### 1.1 – Make a New SSH Key |
20 | 15 |
|
| 16 | +```bash |
21 | 17 | ssh-keygen -t ed25519 -C "your_email@example.com" |
| 18 | +``` |
22 | 19 |
|
23 | | -Press Enter to save in the default location |
24 | | - |
25 | | -Press Enter again for no passphrase (or type one for extra security) |
| 20 | +* Press **Enter** to save in the default place |
| 21 | +* Press **Enter** again when asked for passphrase (or type one to protect your key) |
26 | 22 |
|
| 23 | +### 1.2 – Start the SSH Agent |
27 | 24 |
|
28 | | -⚙️ 1.2 – Start the SSH Agent |
29 | | - |
| 25 | +```bash |
30 | 26 | eval "$(ssh-agent -s)" |
| 27 | +``` |
31 | 28 |
|
32 | | -➕ 1.3 – Add Your SSH Key to the Agent |
| 29 | +### 1.3 – Add Your SSH Key to the Agent |
33 | 30 |
|
| 31 | +```bash |
34 | 32 | ssh-add ~/.ssh/id_ed25519 |
| 33 | +``` |
35 | 34 |
|
36 | | -📋 1.4 – Copy Your SSH Key |
| 35 | +### 1.4 – Copy Your SSH Key |
37 | 36 |
|
| 37 | +```bash |
38 | 38 | cat ~/.ssh/id_ed25519.pub |
| 39 | +``` |
39 | 40 |
|
40 | | -Copy the full key (starts with ssh-ed25519) |
41 | | - |
| 41 | +* Copy the full key (starts with `ssh-ed25519`) |
42 | 42 |
|
43 | | -🔗 1.5 – Add the Key to GitHub |
| 43 | +### 1.5 – Add the Key to GitHub |
44 | 44 |
|
45 | | -Open GitHub SSH settings |
| 45 | +* Go to [GitHub SSH settings](https://github.com/settings/keys) |
| 46 | +* Click **New SSH key** |
| 47 | +* Paste your key and save it |
46 | 48 |
|
47 | | -Click New SSH key |
48 | | - |
49 | | -Paste your key, give it a name, and save |
50 | | - |
51 | | - |
52 | | -✅ 1.6 – Test If SSH Works |
| 49 | +### 1.6 – Test If SSH Works |
53 | 50 |
|
| 51 | +```bash |
54 | 52 | ssh -T git@github.com |
55 | | - |
56 | | -You should see: |
57 | | - |
58 | | - |
59 | | -Hi username! You've successfully authenticated, but GitHub does not provide shell access. |
60 | | - |
| 53 | +``` |
61 | 54 |
|
62 | 55 | --- |
63 | 56 |
|
64 | | -🧾 2. Set Git Name and Email (Do Once) |
65 | | - |
66 | | -👤 Configure Your Identity |
| 57 | +## 🧾 2. Set Git Name and Email (Do Once) |
67 | 58 |
|
| 59 | +```bash |
68 | 60 | git config --global user.name "Your Name" |
69 | 61 | git config --global user.email "your@email.com" |
| 62 | +``` |
70 | 63 |
|
71 | | -🔍 Check Current Settings |
| 64 | +To check: |
72 | 65 |
|
| 66 | +```bash |
73 | 67 | git config --global user.name |
74 | 68 | git config --global user.email |
75 | | - |
76 | | -🔒 Optional: Mark Folder as Safe (Avoid Warnings) |
77 | | - |
78 | | -git config --global --add safe.directory ... |
79 | | - |
| 69 | +``` |
80 | 70 |
|
81 | 71 | --- |
82 | 72 |
|
83 | | -⬆️ 3. Upload Files to GitHub Using SSH |
| 73 | +## ⬆️ 3. Upload Files to GitHub Using SSH |
84 | 74 |
|
85 | | -🌿 3.1 – Set main as Default Branch (Do Once) |
| 75 | +### 3.1 – Set `main` as Default Branch (Do Once) |
86 | 76 |
|
| 77 | +```bash |
87 | 78 | git config --global init.defaultBranch main |
| 79 | +``` |
88 | 80 |
|
89 | | -🆕 3.2 – Make a New GitHub Repo |
90 | | - |
91 | | -Go to Create New Repo |
92 | | - |
93 | | -Name your repo |
94 | | - |
95 | | -Uncheck “Initialize with README” |
96 | | - |
97 | | -Click Create repository |
| 81 | +### 3.2 – Make a New GitHub Repo |
98 | 82 |
|
| 83 | +* Go to [https://github.com/new](https://github.com/new) |
| 84 | +* Give it a name, uncheck **README**, and create it |
99 | 85 |
|
100 | | -📁 3.3 – Create Local Folder and Git Repo |
| 86 | +### 3.3 – Create Local Folder and Git Repo |
101 | 87 |
|
| 88 | +```bash |
102 | 89 | mkdir my-repo |
103 | 90 | cd my-repo |
104 | 91 | git init |
| 92 | +``` |
105 | 93 |
|
106 | | -📄 3.4 – Add a File and Commit |
| 94 | +### 3.4 – Add a File and Save It |
107 | 95 |
|
| 96 | +```bash |
108 | 97 | echo "Hello GitHub" > file.txt |
109 | 98 | git add file.txt |
110 | 99 | git commit -m "Initial commit" |
| 100 | +``` |
111 | 101 |
|
112 | | -🔗 3.5 – Connect to GitHub and Upload |
| 102 | +### 3.5 – Connect to GitHub and Upload |
113 | 103 |
|
| 104 | +```bash |
114 | 105 | git remote add origin git@github.com:your-username/my-repo.git |
115 | 106 | git branch -M main |
116 | 107 | git push -u origin main |
117 | | - |
| 108 | +``` |
118 | 109 |
|
119 | 110 | --- |
120 | 111 |
|
121 | | -⬇️ 4. Download a GitHub Repo Using SSH |
122 | | - |
123 | | -📎 4.1 – Copy SSH Link from GitHub |
| 112 | +## ⬇️ 4. Download a GitHub Repo Using SSH |
124 | 113 |
|
125 | | -Go to your repo → Code → SSH |
| 114 | +### 4.1 – Copy SSH Link from GitHub |
126 | 115 |
|
127 | | -Copy the SSH link |
| 116 | +* Click **Code** → **SSH** and copy it |
128 | 117 |
|
| 118 | +### 4.2 – Clone It |
129 | 119 |
|
130 | | -📥 4.2 – Clone It |
131 | | - |
| 120 | +```bash |
132 | 121 | git clone git@github.com:your-username/my-repo.git |
133 | | - |
| 122 | +``` |
134 | 123 |
|
135 | 124 | --- |
136 | 125 |
|
137 | | -> 🎉 All done! You can now securely push and pull code with GitHub using SSH. |
138 | | -
|
139 | | - |
140 | | - |
| 126 | +> ✅ Done! You’re all set to use Git and GitHub with SSH. |
0 commit comments