Git
How toEdit
# sudo apt update && sudo apt upgrade # y # git --version # sudo apt install git
# git clone https://github.com/mianqi2016/MCS-51_sdcc # cd MCS-51_sdcc # ls # rm -r 006_gpio # ls # git add . # git commit -m "Removed 006_gpio directory" Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got '***@***-HP-Z228-Microtower-Workstation.(none)') # git config --global user.email "***@***.com" # git config --global user.name "******" # git config --global --list user.email=***@***.com user.name=****** $ git commit -m "Removed 006_gpio directory" [main 69703fb] Removed 006_gpio directory 1 file changed, 1 deletion(-) delete mode 100644 006_gpio/gpio_stepper_28byj-48.c
$ git push
Username for 'https://github.com': ***
Password for 'https://***@github.com':
remote: {"auth_status":"auth_error","body":"Invalid username or token. Password authentication is not supported for Git operations."}
fatal: Authentication failed for 'https://github.com/***/MCS-51_sdcc/'
Use Personal Access Tokens (PATs):
1.Log in to GitHub and go to Settings > Developer settings > Personal access tokens.
2.Click Generate new token, provide a name, and select required scopes (e.g., repo for repository access).
3.Copy the generated token and store it securely.
4.Use the token as your password when prompted during Git operations:
Username for 'https://github.com': ***
Password for 'https://***@github.com':
remote: {"auth_status":"access_denied_to_user","body":"Permission to ***/MCS-51_sdcc.git denied to ***"}
fatal: unable to access 'https://github.com/***/MCS-51_sdcc/': The requested URL returned error: 403
Username for 'https://github.com': ***
Password for 'https://***@github.com':
remote: {"auth_status":"auth_error","body":"Invalid username or token. Password authentication is not supported for Git operations."}
fatal: Authentication failed for 'https://github.com/***/MCS-51_sdcc/'
at the end of the file name type a “/” to initilize it as a folder.
- How to Add Folders to GitHub
- How to Delete a Git Repository
- Git Update
- Getting changes from a remote repository
- Setting repository visibility
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings. Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline. In the "Danger Zone" section, to the right of to "Change repository visibility", click Change visibility. Select a visibility. To verify that you're changing the correct repository's visibility, type the name of the repository you want to change the visibility of. Click I understand, change repository visibility.
TokenEdit
Error: Permission denied (publickey)Edit
- Adding a new SSH key to your GitHub account
- Checking for existing SSH keys
- Generating a new SSH key and adding it to the ssh-agent
$ ssh -vT git@github.com ... debug1: Trying private key: /home/mq/.ssh/id_dsa debug1: No more authentication methods to try. git@github.com: Permission denied (publickey). $ ssh -T git@github.com git@github.com: Permission denied (publickey). $ ssh-add -l -E sha256 The agent has no identities. $ eval "$(ssh-agent -s)" Agent pid 12909 $ ssh-add -l The agent has no identities.ls -al ~/.ssh total 12 drwx------ 2 *** *** 4096 Sep 30 10:45 . drwxr-x--- 20 *** *** 4096 Sep 29 16:55 .. -rw------- 1 *** *** 0 Sep 22 18:39 authorized_keys -rw-r--r-- 1 *** *** 142 Sep 30 10:45 known_hosts $ ssh-keygen -t ed25519 -C "mian.qi@outlook.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/home/***/.ssh/id_ed25519): github_key Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in github_key Your public key has been saved in github_key.pub The key fingerprint is: SHA256:***** ***@***.com The key's randomart image is: +--[ED25519 256]--+ | .o+. .oo.. | | +.=.oooo . | | . * +.o+ . | | . * E.o . | | . S .. . | | o .o .. | | o .o.+. .| | o +.o+Bo. | | ooo o=O.+o | +----[SHA256]-----+
Generate a Personal Access TokenEdit
1. Open your GitHub account settings by clicking on your profile picture in the top right corner and selecting “Settings” from the dropdown menu. 2. In the left sidebar, click on “Developer settings” and then select “Personal access tokens”. 3. Click on the “Generate new token” button. 4. Give your token a descriptive name in the “Note” field to easily identify it later. 5. Select the desired scopes for your token. For Git operations, you need to select the “repo” scope. 6. Click on the “Generate token” button at the bottom of the page. 7. GitHub will generate a new personal access token for you. Make sure to copy this token and keep it in a safe place. Note that this token will only be displayed once, so make sure to copy it before leaving the page.
How to use a tokenEdit
$ git clone https://github.com/USERNAME/REPO.git Username: YOUR_USERNAME Password: YOUR_PERSONAL_ACCESS_TOKEN git config --global --unset credential.helper // 清除用户名和密码的 cache git push Username for 'https://github.com': 此处输入用户名 Password for 'https://mianqi2016@github.com': 此处粘贴 token 之后,点击 "Enter"
Git Credential ManagerEdit
- Install instructions
- GCM 2.5.0
- Command-line usage
- 7.14 Git Tools - Credential Storage
- Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services.
GitHub Issues/ProjectsEdit
- About Projects - Projects is an adaptable, flexible tool for planning and tracking work on GitHub.
- Creating a project - Learn how to create an organization or user project.
- Changing the layout of a view - You can view your project as a high-density table, as a kanban board, or as a timeline-style roadmap.
- Editing items in your project - There are several methods you can use within your project to quickly make changes to multiple items.
- Adding items to your project - Learn how to add pull requests, issues, and draft issues to your projects individually or in bulk.
Github - setup new repositoryEdit
TutorialEdit
- Git commands
- gittutorial - A tutorial introduction to Git
- Git Tutorial: A Comprehensive Guide
- Git --fast-version-contro
- Git - Reference
- An Intro to Git and GitHub for Beginners (Tutorial)
- How To Use GitHub – Developers Collaboration Using GitHub
- How to Install Latest Git Version on Ubuntu
CommandEdit
$ git config --global user.name "John Doe" $ git config --global user.email johndoe@example.com
git cloneEdit
git clone https://github.com/mianqi2016/MCS-51_sdcc.git git reset --help git reset git add ERRORs.txt git commit -m "add ERRORs.txt" git push
- Managing your personal access tokens
- Cloning with HTTPS URLs
- Git Credential Manager
- git-credential-manager/docs/install.md
- GCM 2.4.1
git pullEdit
moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git add 018* moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git commit -m "add 018_da_BCD.asm" On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git push Username for 'https://github.com': mianqi2016 Password for 'https://mianqi2016@github.com': To https://github.com/mianqi2016/MCS-51_asm.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/mianqi2016/MCS-51_asm.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ ls 000_51asm.asm 007_mul.asm 014_max_find.asm 001_51asm.asm 008_mul_1.asm 015_max_find_bubble.asm 002_anl_orl.asm 009_bank.asm 016_ascend.asm 003_toggle_port.asm 010_stack_push_pop.asm 017_descend.asm 004_xrl.asm 011_uart_polling.asm 018_da_BCD.asm 005_timer_500us.asm 012_isr.asm README.md 006_add.asm 013_uart_interrupt.asm moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ cd .. moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm$ git push --help moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm$ git pull --help moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm$ cd MCS* moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git pull https://github.com/mianqi2016/MCS-51_asm remote: Enumerating objects: 8, done. remote: Counting objects: 100% (8/8), done. remote: Compressing objects: 100% (6/6), done. remote: Total 6 (delta 4), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (6/6), 1.87 KiB | 955.00 KiB/s, done. From https://github.com/mianqi2016/MCS-51_asm * branch HEAD -> FETCH_HEAD hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches. moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git push Username for 'https://github.com': mianqi2016 Password for 'https://mianqi2016@github.com': To https://github.com/mianqi2016/MCS-51_asm.git ! [rejected] main -> main (non-fast-forward) error: failed to push some refs to 'https://github.com/mianqi2016/MCS-51_asm.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git config pull.rebase false moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git pull https://github.com/mianqi2016/MCS-51_asm From https://github.com/mianqi2016/MCS-51_asm * branch HEAD -> FETCH_HEAD Merge made by the 'ort' strategy. 017_descend.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$ git push Username for 'https://github.com': mianqi2016 Password for 'https://mianqi2016@github.com': Enumerating objects: 7, done. Counting objects: 100% (7/7), done. Delta compression using up to 8 threads Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 1.39 KiB | 1.39 MiB/s, done. Total 5 (delta 2), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (2/2), completed with 1 local object. To https://github.com/mianqi2016/MCS-51_asm.git dfd673b..bc3207d main -> main moonriverzf@moonriverzf-HP-Compaq-Elite-8380-MT:~/mcs-51_asm/MCS-51_asm$
git commitEdit
- Git Commit -a: Stage & Commit Files in a Single Step
- Where is the Git config file stored?
- Changing a commit message
- Git Guides - Git Commit
git pushEdit
- How to Push Changes to a Remote Repository with Git Push
- git remote set-url to change remote repo URL [With Examples]
- How to Authenticate Git Push with Github Using a Token?
