Concise git tutorial (single-user version) and git tutorial
Recently, I started to write a relatively large project, so I need to use git. I have been using SVN built with Kingsoft kubernetes and turtles. Recently I want to try git.
1. Install
Ubuntu:
1 sudo apt-get install git
In earlier versions of Ubuntu:
1 sudo apt-get install git-core
For other versions of Linux, You need to download the source code from the official website for installation.
1 ./config2 make3 sudo make install
2. Create a version Library
Mkdir sexybearcd sexybearpwd (pwd
Command to display the current directory) git init (git init
Command to change this directory to a Git-managed repository)
Now go to the sexybear folder and. git directory. This indicates that the repository has been created. If yes, it will not fail. It may be that the directory is hidden and you can use ls-ah to view it.
A repository that can be managed by git is created, and the next step is how to add files.
First, create a new file in the sexybeardirectory, such as readme.txt.
Then, execute the following command to tell git that you have added a file.
1 git add readme.txt2 git commit -m "wrote a readme file"
3. Version Control
1. view the git status and specific changes
1 git status2 git diff readme.txt
The second directive shows the specific changes to the readme.txt file.
2. Version rollback
1 git log2 git log -- pretty = oneline3 git reset -- hard HEAD ^ (back to the previous version) 4 git reset -- hard 3628164 (back to the specified version number, the version number can be obtained in log)
3. Cancel Modification
Git checkout -- readme.txt (readme.txt
All file modifications in the workspace are revoked)
4. delete an object
Git rm readme.txt (delete the files that have been submitted to the repository)
Now these commands are enough for single-person work. I don't need them for team work yet, so they won't be involved and will be improved in the future.