Some references :
https://1drv.ms/w/s!AndI1JV-h1Q5q3cxK0-DDgsu3kpQ?e=fFEAYX
https://blog.csdn.net/weixin_43142797/article/details/105869056
https://miahsuwork.medium.com/第一週-版本控制與-git-基本指令-fa3c4ba286a2
https://miahsuwork.medium.com/第二週-git-本地端與遠端操作-github-78eec4537179
Other references :
https://medium.com/@flyotlin/新手也能懂的git教學-c5dc0639dd9
https://stackoverflow.com/questions/12940626/github-error-message-permission-denied-publickey
https://blog.csdn.net/ppt_no1/article/details/126612236
sudo apt-get install git
git --version
//Setup your account
git config --global user.name ""
git config --global user.email
git config --list
git clone --single-branch --branch=<branch name> <url>
git status
git status --short
git remote -v
git log
git diff
##Edit the url
git remote set-url origin url
##Add a new url
git remote add myorigin url
#Delete
git remote rm name
git remote remove name
git init
git add <file name>
git add . //Add all the files in currnet folder.
git commit -m "" //Put the describtion message.
git branch -M main
git remote add origin <url>
git push -u origin main //-u can specitfy the upstream
git checkout -b 你的分支名
git checkout 已存在的分支名
ubuntu@ubuntu:~$ git push -u origin main
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
ubuntu@ubuntu:~$ ssh -T git@github.com
git@github.com: Permission denied (publickey).
Solution 1
ssh-keygen -t rsa -C "jimmy20152811@gmail.com"
cd .ssh
nano id_rsa.pub
ubuntu@ubuntu:~$ ssh -T git@github.com
Hi jimmy20152811! You've successfully authenticated, but GitHub does not provide shell access.
Solution 2
ubuntu@ubuntu:~$ git remote add ori https://github.com/jimmy20152811/Free5GC_3.3_test
ubuntu@ubuntu:~$ git remote -v
ori https://github.com/jimmy20152811/Free5GC_3.3_test (fetch)
ori https://github.com/jimmy20152811/Free5GC_3.3_test (push)
origin git@github.com:jimmy20152811/Free5GC_3.3_test.git (fetch)
origin git@github.com:jimmy20152811/Free5GC_3.3_test.git (push)
ubuntu@ubuntu:~$ git push -u ori main
Username for 'https://github.com': Jimmy
Password for 'https://Jimmy@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/jimmy20152811/Free5GC_3.3_test/'
ubuntu@ubuntu:~$ git push -u ori main
Username for 'https://github.com': Jimmy
Password for 'https://Jimmy@github.com':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/jimmy20152811/Free5GC_3.3_test/'
git config --global --add safe.directory /home/jimmy/free5gc_backup/free5gc_PCF_v0.1
sudo chown -R $USER:$USER /home/jimmy/free5gc_backup/free5gc_PCF_v0.1
git push -u origin v3.3_AUSF-NSSF-PCF_v0.1
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: free5gc_v3.3_01 (modified content, untracked content)
ubuntu@ubuntu:~/free5gc$ git status
Not currently on any branch.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: Makefile
modified: NFs/amf (modified content)
modified: NFs/nrf (modified content)
modified: config/amfcfg.yaml
modified: config/smfcfg.yaml
modified: config/upfcfg.yaml
modified: run.sh
no changes added to commit (use "git add" and/or "git commit -a")
rm -rf .git