howto:github
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| howto:github [2020/06/30 21:28] – created Wuff | howto:github [2025/10/21 20:53] (current) – [Create repository] Wuff | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| https:// | https:// | ||
| + | ===== Create repo on github ===== | ||
| + | < | ||
| + | curl -H ' | ||
| + | curl -u ' | ||
| + | |||
| + | curl -u USERNAME: | ||
| + | </ | ||
| + | |||
| + | ===== Create repository ===== | ||
| + | |||
| + | < | ||
| + | cd context.youtube.dl.menu/ | ||
| + | git config --global init.defaultBranch main | ||
| + | git init | ||
| + | Initialised empty Git repository in / | ||
| + | git add . | ||
| + | git commit -m " | ||
| + | git remote add origin git@github.com: | ||
| + | git push -u origin master | ||
| + | </ | ||
| + | |||
| + | ===== Generate SSH key for github access ===== | ||
| + | |||
| + | < | ||
| + | eval $(ssh-agent -s) | ||
| + | ssh-keygen -t rsa -b 4096 -C "key comment" | ||
| + | ## you'll be prompted to a couple of times. Press enter for the first prompt. choose a passphrase for the second prompt, or press enter twice for no passphrase | ||
| + | ssh-add ~/ | ||
| + | cat ~/ | ||
| + | curl -u USERNAME: | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Creating a personal access token ===== | ||
| + | |||
| + | NOTE: As a security precaution, GitHub automatically removes personal access tokens that haven' | ||
| + | |||
| + | https:// | ||
| + | - In the upper-right corner of any page, click your profile photo, then click Settings. | ||
| + | - In the left sidebar, click Developer settings. | ||
| + | - In the left sidebar, click Personal access tokens. | ||
| + | - Click Generate new token. | ||
| + | - Give your token a descriptive name. | ||
| + | - Select the scopes, or permissions, | ||
| + | - Click Generate token. | ||
| + | - Click to copy the token to your clipboard. For security reasons, after you navigate off the page, you will not be able to see the token again. | ||
| + | |||
| + | Warning: Treat your tokens like passwords and keep them secret. When working with the API, use tokens as environment variables instead of hardcoding them into your programs. | ||
| + | |||
| + | ===== Using a token on the command line ===== | ||
| + | |||
| + | Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS. | ||
| + | |||
| + | For example, on the command line you would enter the following: | ||
| + | < | ||
| + | $ git clone https:// | ||
| + | Username: your_username | ||
| + | Password: your_token | ||
| + | </ | ||
| + | |||
| + | ===== Removing git history ===== | ||
| + | < | ||
| + | git checkout --orphan newBranch | ||
| + | git add -A # Add all files and commit them | ||
| + | git commit | ||
| + | git branch -D master | ||
| + | git branch -m master | ||
| + | git push -f origin master | ||
| + | git gc --aggressive --prune=all | ||
| + | |||
| + | #rename url on github.com if desired, then update the url: | ||
| + | git remote set-url origin newURL | ||
| + | </ | ||
| + | |||
| + | ===== Rebase with fork master ===== | ||
| + | Example fork of repo mainuser/ | ||
| + | < | ||
| + | git clone git@github.com: | ||
| + | cd interestingrepo | ||
| + | git remote add upstream git@github.com: | ||
| + | </ | ||
| + | |||
| + | To update: | ||
| + | < | ||
| + | git fetch upstream | ||
| + | git rebase upstream/ | ||
| + | </ | ||
| + | |||
| + | ===== Change last commit message ===== | ||
| + | |||
| + | < | ||
| + | git commit --amend -m "New message" | ||
| + | git push --force repository-name branch-name | ||
| + | </ | ||
| + | |||
| + | ===== Git Credentials ===== | ||
| + | |||
| + | < | ||
| + | then: | ||
| + | < | ||
| + | git push http:// | ||
| + | Username: <type your username> | ||
| + | Password: <type your password> | ||
| + | |||
| + | [several days later] | ||
| + | git push http:// | ||
| + | [your credentials are used automatically] | ||
| + | </ | ||
| + | |||
| + | Passwords stored in plain text, each on their own line in URL format: | ||
| + | <code ~/ | ||
| + | https:// | ||
| + | </ | ||
| + | |||
| + | ===== Forceful undo last commit ===== | ||
| + | < | ||
| + | git reset --hard HEAD^ | ||
| + | git push origin -f | ||
| + | </ | ||
howto/github.1593548895.txt.gz · Last modified: (external edit)