Advertisement
efxtv

Guide to Managing GitHub Repositories Using the Terminal

Sep 4th, 2024 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | Cybersecurity | 0 0
  1. ✨️ Guide to Managing GitHub Repositories Using the Terminal
  2. - File Size Limits on GitHub
  3. - Individual File Size Limit: 100 MB allowed to be pushed to the repository.
  4. - Git Large File Storage (LFS): For files larger than 100 MB, GitHub recommends using Git LFS, which supports files up to 2 GB. Git LFS requires additional setup and has its own storage and bandwidth limitations.
  5.  
  6. ✨️ Login and push files from termianl:
  7. - Create and Set Up an SSH Key
  8. - Generate a New SSH Key
  9. - ssh-keygen -t ed25519 -C "[email protected]"
  10. -t ed25519: Specifies the type of key to create. ed25519 is a modern and secure choice.
  11. -C "[email protected]": Adds a label (your email) to the key for identification.
  12.  
  13. ✨️ Copy publicey and paste in github ssh
  14. - cat ~/.ssh/id_ed25519.pub
  15. - Copy the entire output.
  16.  
  17. ✨️ Add the SSH Key to GitHub
  18. - go to https://github.com/settings/keys or
  19. - Navigate to Settings > SSH and GPG keys.
  20. - Click New SSH key.
  21. - Paste your copied SSH key into the "Key" field.
  22. - Give it a descriptive title (e.g., "My Laptop Key").
  23. - Click Add SSH key.
  24. - Direct Link to Add SSH Key
  25.  
  26. ✨️ Clone a Repository
  27. - To clone an existing repository using SSH
  28. - git clone [email protected]:username/repository.git
  29. - Replace username/repository with your repository’s path.
  30. - For example: git clone [email protected]:bobo2/store.git
  31.  
  32. ✨️ Navigate into the cloned repository:
  33. - cd repository
  34. - To copy files into your repository directory:
  35. - cp /path/to/your/file ./file
  36.  
  37. Stage the files for commit:
  38. - git add .
  39. - git status
  40. - git commit -m "Add description of changes"
  41.  
  42. ✨️ Configure Git User Information
  43. - Set your global Git username and email:
  44. - git config --global user.email "[email protected]"
  45. - git config --global user.name "your profile name"
  46.  
  47. ✨️ Push Changes to GitHub
  48. - git push origin main
  49.  
  50. ✨️ Install GH
  51. - Install GitHub CLI
  52. - sudo apt install gh
  53.  
  54. ✨️ Login and Authenticate with GitHub CLI
  55. - gh auth login
  56. - Choose SSH as the authentication method.
  57. - Follow the prompts to generate and paste a personal access token. You can create a token here.
  58.  
  59. ✨️ Create a new public repository with:
  60. - gh repo create my-new-repo --public --description "A description of my new repository"
  61. - or
  62. - gh repo create test123 --public
  63.  
  64. ✨️ Clone the New Repository and Add Files
  65. - gh repo clone temp-storage
  66. - or
  67. - git clone https://github.com/username/temp-storage.git
  68.  
  69. ✨️ Navigate into the repository directory:
  70. - cd temp-storage
  71. - cp ~/files.txt .
  72.  
  73. ✨️ Initialize and Push Your Code
  74. - git init
  75. - git add .
  76. - git status
  77. - git commit -m "Initial commit"
  78. - git remote add origin [email protected]:username/repository-name.git
  79. - git remote -v
  80. - git push -u origin main
  81.  
  82. ✨️ Delete a File from a Repository
  83. - Navigate to your repository directory:
  84. - cd repository
  85.  
  86. ✨️ Remove the file:
  87. - git rm path/to/file
  88.  
  89. ✨️ Commit the change:
  90. - git commit -m "Remove file"
  91.  
  92. ✨️ Push the changes to GitHub:
  93. - git push origin main
  94.  
  95. ✨️ Delete a Repository Using GitHub CLI
  96. - Ensure you are authenticated with gh.
  97. - gh repo delete username/repository --confirm
  98.  
  99. ✨️ List all repositories
  100. - gh repo list username
  101.  
  102. Work with existing repository
  103. - check for remote (working repository)
  104. - git remote -v
  105. - Change remote
  106. - cd test-repository
  107. - gh repo fork
  108.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement