How to use Git
Recommended (free): Git usage tutorial
Set up Git
First Go to the Git official website to download Git, and finally get Git Bash Git Cmd Git GUI
Open Git Bash, enter your username and email address
$ git config --global user.name "jiangjievior"
$ git config - -global user.email “1534410005@qq.com”-
Use Git
Create a folder for Git work github
Open Git Cmd and switch to this directory , enter
git init
to create the file hello.txt in the folder
means to initialize the folder as the working folder of Git
add the file to Git
git add hello.txt
Indicate notes for adding files this time
git commit -m "Added hello.txt"
After modifying the file, add new files again and add notes
git add hello.txt
git commit -m "A sentence was added to hello.txt"
View the records of each file added in the past
git log
Finally get each record, you can return the previous records through the specified id after commit File
commit 88d885c21216cbedacb1692e08d51afa6d4e32a7 (HEAD -> master)
Author: yepdlpc mattbaisteins@gmail.com
Date: Wed Dec 19 20:13:22 2018 0800Add in hello.txt One sentence
commit ec4652d5d0b8662fc8730d64b42341d1c363a442
Author: yepdlpc mattbaisteins@gmail.com
Date: Wed Dec 19 20:11:42 2018 0800
添加了hello.txt
Return the file to the previously specified version (1 here represents the return to the last time)
git reset --hard HEAD^1
Return to the previously specified file through the beginning of part of the id code
git reset --hard 88d885
View every previous modification to the file
git reflog
Git Hub usage tutorial
1. Create public and private keys
Click on GIt bash to open the command window
Enter: ssh- keygen -t rsa -C "name", "email", name is the user name, Email is your email
For example:
$ ssh-keygen -t rsa -C "jiangjievior", "1534410005@qq. com”
2. File upload and download
Create a folder with the same name as the warehouse in Git Hub in the computer directory, and use Git commands to bind to upload and download
- Upload local files to Git Hub repository
Switch Git Cmd to the newly created directory and set the directory as Git repository
git init
Upload the file to Git repository and add remark information (git add * can be used once Add all files)
git add hello.txt
git commit -m "first commit"
If the next step is unsuccessful, perform the following and delete the existing association in advance
git remote rm origin
Connect the local Git repository with the remote Git Hub repository
git remote add origin git@github.com:MachinePlay/Gittest.git
git@github.com:MachinePlay/Gittest. git is the SSH code of the warehouse in Git Hub, as shown below:
Push all the contents of the local Git warehouse to the remote Git Hub warehouse
git push -u origin master
Since the remote library is Empty. When we pushed the master branch for the first time, we added the -u parameter. Git will not only push the contents of the local master branch to the remote new master branch, but also associate the local master branch with the remote master branch. , the commands can be simplified when pushing or pulling in the future.
After that, you can use git add git commit-m
git push origin master
The process is as follows:
git init
git remote rm origin (maybe not needed)
git remote add origin git@github.com:jiangjievior/python-.git
git status (view uploaded files)
git add hello.txt (or git add *)
git commit - m “first commit”
git push -u origin master
- Download the Git Hub warehouse file to the local
First use Git Cmd to switch to a local directory to receive the download File
By entering the Git Hub warehouse SSH code, use the following statement to upload the file to the Git Hub warehouse
git clone git@github.com:smuyyh/BookReader.git
The above is the detailed content of How to use Git. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



GitHub is not difficult to learn. 1) Master the basic knowledge: GitHub is a Git-based version control system that helps track code changes and collaborative development. 2) Understand core functions: Version control records each submission, supporting local work and remote synchronization. 3) Learn how to use: from creating a repository to push commits, to using branches and pull requests. 4) Solve common problems: such as merge conflicts and forgetting to add files. 5) Optimization practice: Use meaningful submission messages, clean up branches, and manage tasks using the project board. Through practice and community communication, GitHub’s learning curve is not steep.

Microsoft does not own Git, but owns GitHub. 1.Git is a distributed version control system created by Linus Torvaz in 2005. 2. GitHub is an online code hosting platform based on Git. It was founded in 2008 and acquired by Microsoft in 2018.

Git and GitHub are not the same thing. Git is a version control system, and GitHub is a Git-based code hosting platform. Git is used to manage code versions, and GitHub provides an online collaboration environment.

On your resume, you should choose to write Git or GitHub based on your position requirements and personal experience. 1. If the position requires Git skills, highlight Git. 2. If the position values community participation, show GitHub. 3. Make sure to describe the usage experience and project cases in detail and end with a complete sentence.

Starting from Git is more suitable for a deep understanding of version control principles, and starting from GitHub is more suitable for focusing on collaboration and code hosting. 1.Git is a distributed version control system that helps manage code version history. 2. GitHub is an online platform based on Git, providing code hosting and collaboration capabilities.

GitLab is better for some developers and teams because it provides a complete DevOps toolchain and powerful CI/CD capabilities. 1. GitLab's CI/CD function is integrated within the platform, supporting full process automation from code submission to deployment. 2. Its server-side rendering technology improves page loading speed for large projects. 3. GitLab's permission management system is more flexible and supports fine-grained control.

The reason for using GitHub to manage HTML projects is that it provides a platform for version control, collaborative development and presentation of works. The specific steps include: 1. Create and initialize the Git repository, 2. Add and submit HTML files, 3. Push to GitHub, 4. Use GitHubPages to deploy web pages, 5. Use GitHubActions to automate building and deployment. In addition, GitHub also supports code review, Issue and PullRequest features to help optimize and collaborate on HTML projects.

Git is an open source distributed version control system that helps developers track file changes, work together and manage code versions. Its core functions include: 1) record code modifications, 2) fallback to previous versions, 3) collaborative development, and 4) create and manage branches for parallel development.
