Many people think Git is too confusing or complex version control system. This article is for some people who want to get started with git quickly,
For most basic requirements, this article covers 70% to 90% of usage
Before using git, you need to establish a repository. You can use an existing directory as a git repository or create an empty directory
Using your current directory as the GIT repository, we just need to initialize it
Use our specified directory as the GIT repository
From now on, we will assume that you are in the root directory of GIT repository, unless otherwise specified
Add new file
We have a repository, but there is nothing. You can use the add command to add files
You can use add... To continue adding task files
Now that we've added these files, we want them to actually be saved in the GIT repository,
To do this, we submit them to the warehouse
git commit -m "Adding files"
If you don't use - m, an editor will appear to let you write your own comments
When we modify a lot of files and do not want to add each file, and want to commit to submit local changes automatically, we can use the - a identifier
git commit -a -m "Changed some files"
The - a option of the GIT commit command can only change all</span> Modified or deleted documents that have been managed by Git Submit to the warehouse.
Please note that - a will not cause a new document to be submitted, it can only be modified.
Let's clone a library from the server and upload it
git clone ssh://example.com/ ~/www/project.git
Now we can push it to the server after modification
git push ssh://example.com/ ~/www/project.git
If you have pushed as above, the following command indicates that the current branch is automatically merged with the only tracking branch.
Updates from a non default location to the specified URL
git pull http://git.example.com/project.git
More than five minutes?
If you want to delete a file from the repository, we use RM
Branching and merging
Branching is done locally and fast. To create a new branch, we use the branch command.
The branch command doesn't take us into the branch, just create one. So we use the checkout command to change the branch.
The first branch, or main branch, is called "master.".
While your branch can be committed, changes will not be reflected in the main branch. When you do, or want to commit changes to the main branch, switch back to the master branch and use merge.
git checkout master git merge test
If you want to delete a branch, we use the - D flag