Git basic usage 1
Reference_Link
菜鸟教程
知乎article
CR\CRLF问题
Github configuration
1 Bsisc usage
Suppose you already install Git succesfully and have a Github account. Then follow steps below to start basic usage of Git
1.1 Create repository on Github
1.2 Bind an account
Name and email correspond to your Github account(maybe not necessary).
git config --global user.name "your_name"git config --global user.email "your_emailps:
globalmeans all your repository in this machine will use this account.
1.3 Set SSH key
cd ~/.ssh or C:\Users\your_account\.ssh, check if you already have file id_rsa and id_rsa.pub, if not, generate through:
ssh-keygen -t rsa -C "your_email
Then just press enter.
1.4 Configure SSH key for Github account.
Click your avatar-click settings-click SSH and GPG keys-copy id_rsa.pub here-click Add key.
1.5 Upload local project to Github
Create a repository
git initgit add file_name-git commit -m "name_of_commit"-git remote add origin git@github.com/repository_address-git branch -M mainthis command change local branch’s name to main which is the same with Github repository’s default name.git push -u origin main
For the next time you just need to run:git add file_namegit commit -m "name_of_commitgit push
1.6 Pull repository to local
Create a repository
git initgit clone remote_repo_url
1.7 Frequently-used Commands
git statusdisplay change of files show repo’s states.git logbrowse commission log.git reset [--soft | --mixed | --hard] [HEAD~n]back to the hsitorical version.
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments




