GitHub Help - halfpintutopia/DA-deutsch-englisch-einfluss GitHub Wiki
Before initialising:
- Install GitHub CLI
brew install gh
- Authenticate with GitHub
gh auth login
- Test connection with SSH
ssh -T [email protected]
- Initialise a Git Repo
git init
git add .
git commit -m "Initial commit"
- 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
-
- Verify remote
git remote -v
git push origin main
- Update repo name
gh repo rename <new-repo-name
- Update the remote URL in my local repo
git remote set-url origin [email protected]:<username>/<new-repo-name>.git
- Verify
git remote -v
git push origin main
# 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
-
git rebase -i HEAD~N
- Replace
N
with the number of commits you want to squash
- Replace
- Opens the interactive editor, and then change "pick" to "squash" (or "s")
- Edit the commit message
- Save to finish
- 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