Linux System | git how to modify the file | git modified files method

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/mdykj33/article/details/102777377

git before submitting the file to the remote repository, you need to first add files to the staging area and committed to the repository, during which we can make changes to the operation.

First, modify the file name

1. Before submission, want to change the file name, you can do this:

$ git mv README.txt README

In fact, the above command runs the equivalent of the following three commands:

$ mv README.txt README
$ git rm README.txt
$ git add README

You can use this time git statusto view the file status:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#new file:   README

2. Following the submission file, if one wants to change the file name, perform steps 1 git mv operation can be.

And then view the file status, then you will be prompted to rename the file:

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:   README.txt -> README
#

When submitted will also remind you:

1 file changed, 0 insertions(+), 0 deletions(-)
rename README.txt => README (100%)

 

Second, modify the contents of the file

1. After submission, if not satisfied with the contents of the file, you can still modify the contents of the file, just need to add the content to the staging area and committed to the repository:

$ git add README
$ git commit -m "modify README"

2. forget to scratch some modifications if just submitted, you can fill the temporary operation, and then run -amend submit:

$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend

The above three commands just produce a final submission, the second amendment submitted command of the first submission.

Finally file can commit changes to the remote repository ~

Guess you like

Origin blog.csdn.net/mdykj33/article/details/102777377