GitHub Help - halfpintutopia/DA-deutsch-englisch-einfluss GitHub Wiki

Create a GitHub Repo with SSH

Before initialising:


  1. Initialise a Git Repo
  • git init
  • git add .
  • git commit -m "Initial commit"
  1. Create a GitHub Repository
  • gh repo create <repo_name> --public --source=. --push --remote=origin
    • --public or --private
    • --source=. create from the current directory
    • --push automatically pushes local commits
    • --remote=ssh set up origin with an SSH URL
  1. Verify remote
  • git remote -v
  • git push origin main

Rename the Repository (SSH)

  1. Update repo name
  • gh repo rename <new-repo-name
  1. Update the remote URL in my local repo
  1. Verify
  • git remote -v
  • git push origin main

Fix the remote repository URL

# check remote configuration
git remote -v

# remote the remote nae and add the correct origin name
git remote remove old_name && git remote add new_name [email protected]:<username>/<new-repo-name>.git

Squashing

Option 1 - Squash Last N Commits into One (Interactive Rebase)

  • git rebase -i HEAD~N
    • Replace N with the number of commits you want to squash
  • Opens the interactive editor, and then change "pick" to "squash" (or "s")
  • Edit the commit message
  • Save to finish

Option 2 - Squash All Commits into One (Reset and Amend)

  • To squash all commits into one
    • git reset --soft $(git rev-list --max-parents=0 HEAD)
    • git commit -m "New squashed commit message"
    • Force push if needed
      • git push --force origin main

## References

⚠️ **GitHub.com Fallback** ⚠️