Advertisement
efxtv

Step-by-step guide to upload all your files to a GitHub repo using SSH

May 31st, 2025
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | Cybersecurity | 0 0
  1. Using SSH keys to interact with GitHub is more secure and avoids typing your username/password or token repeatedly.
  2.  
  3. Step-by-step guide to upload all your files to a GitHub repo using SSH.
  4.  
  5. ##################################################################
  6. Join our telegram channel for more : https://t.me/LinuxClassesEFXTv
  7. ##################################################################
  8.  
  9. ๐Ÿงฐ Prerequisites
  10. - Git installed (git --version)
  11. - GitHub account
  12. - SSH key configured (we'll cover that below)
  13.  
  14. โœ… Step 1: Create an SSH Key (if you don't already have one)
  15.  
  16. Check if you already have a key:
  17. ls ~/.ssh/id_rsa.pub
  18.  
  19. If it exists, you can skip to Step 2.
  20.  
  21. Otherwise, generate one:
  22. ssh-keygen -t ed25519 -C "[email protected]"
  23.  
  24. Press Enter to accept the default file location.
  25. Set a passphrase (optional but recommended).
  26.  
  27. ๐Ÿ“‹ Step 2: Add Your SSH Key to GitHub (Copy the entire output)
  28. cat ~/.ssh/id_ed25519.pub
  29.  
  30. Add it to GitHub:
  31. - Go to https://github.com/settings/keys
  32. - Click "New SSH key"
  33. - Paste the key, give it a name, and save
  34.  
  35. Step 3: Configure SSH for GitHub (optional but helpful)
  36. nano ~/.ssh/config
  37.  
  38. Add this:
  39. Host github.com
  40. HostName github.com
  41. User git
  42. IdentityFile ~/.ssh/id_ed25519
  43.  
  44. ๐Ÿ” Step 4: Test the SSH Connection
  45.  
  46. You should see:
  47. Hi yourusername! You've successfully authenticated, but GitHub does not provide shell access.
  48.  
  49. Step 5: Create a GitHub Repo (via website)
  50. Go to https://github.com/new, create an empty repository without initializing with README.
  51.  
  52. ๐Ÿ“‚ Step 6: Upload Your Files to GitHub (via SSH)
  53. - Navigate to your project folder: (Copy new files if you want to copy)
  54. cd /path/to/your/project
  55.  
  56. Initialize git:
  57. git init
  58.  
  59. Add all files:
  60. git add .
  61.  
  62. Step 7: Set Your Git Identity
  63. git config --global user.name "Your Name"
  64. git config --global user.email "[email protected]"
  65.  
  66. Commit:
  67. git commit -m "Initial commit"
  68.  
  69. ๐Ÿ“‚ Step 7:Add your GitHub repo via SSH:
  70. git remote add origin [email protected]:username/repo.git
  71.  
  72. ๐Ÿ“‚ Step 8: Push
  73. git push -u origin main
  74.  
  75. ๐Ÿ“‚ EXTRAS: Delete files and add new files:
  76. ๐Ÿงน 1. Delete the File Locally
  77. rm path/to/file.ext
  78.  
  79. ๐Ÿงน 2. Tell Git About the Deletion:
  80. rm path/to/file.ext
  81.  
  82. ๐Ÿ“Œ adds changes to tracked files only:
  83. - Stages deleted files
  84. - Stages modified files
  85. - Does not stage new (untracked) files
  86. git add -u
  87.  
  88. ๐Ÿ“‚ To Add New Files
  89.  
  90. 1. Copy or create the new files in your repo folder (locally)
  91. cp path/to/nefile.ext .
  92.  
  93. 2. Add the new files to Git:
  94. git add path/to/newfile.ext
  95.  
  96. Or to add everything new:
  97. git add .
  98.  
  99. ๐Ÿ“ Commit the Changes
  100. git commit -m "Remove unused files and add new ones"
  101.  
  102. ๐Ÿš€ Push to GitHub
  103. git push
  104.  
  105. ๐Ÿงฝ Optional: Delete a Remote File Without Deleting It Locally
  106. git rm --cached path/to/file.ext
  107.  
  108. ๐Ÿ“‚ How to rename a file/folder in Git (do not use .ext for folders):
  109.  
  110. 1. Use git mv to rename:
  111. git mv old_filename.ext new_filename.ext
  112.  
  113. 2. Commit the rename:
  114. git commit -m "Rename old_filename.ext to new_filename.ext"
  115.  
  116. 3. Push the changes (if you use remote repo):
  117. git push
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement