Skip to main content

GitCommit

AndyBinOriginalAbout 1 min

Conclusion

Initialize local repository:

git init

Add files to repository:

# add single file
git add <file>

# add multiple files
git add file1 file2 ...

# add all modified files
git add .

Commit files to repository:

git commit -m "Caption"

Caption

What is a repository? The version library is also known as the repository in English. You can simply understand it as a directory. All files in this directory can be managed by Git. The modification and deletion of each file can be tracked by Git, so that the history can be tracked at any time, or the files can be restored at some time in the future.

Step

First, select an appropriate place, create an empty directory, and execute in this directory:

git init

At this point, a repository is created, and a git hidden file. This file is the configuration file of git. Please do not modify it at will; Next, add a file to the repository, create a new readme.txt, and execute:

git add readme.txt

Then commit the file to the repository and execute:

git commit -m "Your comments"

The results are as follows:

$ git commit -m "first commit"
[master (root-commit) 6999761] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 readme.txt

Tips

The description of this commit is entered after -m. You can enter any content, which is of course meaningful, so that you can easily find the change record from the history.
After the command git commit is executed successfully, you will be informed1 file changed:1 file has been changed (our newly added readme.txt file);1 insertions:A line is inserted (readme.txt has a line).

Last update:
Contributors: rumosky
Comments
  • Latest
  • Oldest
  • Hottest