All operations are performed under root privileges, and non-root users may need elevated privileges.
- First install git
- yum install git
- Generate ssh key:
- ssh-keygen -t rsa -C "[email protected]", then press Enter all the way to use the default settings.
- View the contents of the ssh public key file
- By default, all contents of the file are copied to /root/.ssh/id_rsa.ssh
- 在github上 -- Personal settings -- SSH and GPG keys -- New SSH key
- Title is the name/mark of this key
- Paste all the contents of the public key file into the Key
- Test whether the ssh key is successful
- ssh -T [email protected], if it prompts You've successfully authenticated, but GitHub does not provide shell access, it means success.
- configure git
- git config --global user.email "mail [email protected]"
- git config --global user.name "github-name"
- upload code
- Create a new repository on github like: myproject.
- Initialize the environment: cd to the project directory, git init
- Add all files in: git add .
- Commit: git commit -m "comment"
- remote: git remote origin Repository URL: git remote origin https://github.com//github-name/myproject.git
- push: git push -u origin master
update code
Step 1: To view the current git repository status, you can use git status
git status
Step 2: Update all
git add *
Step 3: Then enter git commit -m "update description"
git commit -m "更新说明"
Step 4: First git pull, pull the latest code of the current branch
git pull
Step 5: Push to the remote master branch
git push origin master
Not surprisingly, opening GitHub has been synchronized
download code
github download code is roughly divided into three cases
The downloaded code does not need to include git management nor .git files
At this time, click download directly on github to download. At this time, the downloaded code does not contain git management nor .git files.
The downloaded code should include git management but not configure ssh
If you need git management but do not have ssh permission, you can use git clone repo_url to download the code repo_url is the url of the https card header. At this time, the downloaded code does not have the permission to push. If you need to submit modifications through pull request.
The downloaded code should contain ssh for git management configuration
If you need git management and have ssh permissions, you can use git clone [email protected]:xxx/xxx.git to download the code, so that the downloaded code has push permissions.