Git ignore [study notes] file, view changes, undo changes, view submitted

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/A1344714150/article/details/100161910

Ignoring Files

Git can be equipped to provide a strong mechanism to allow users to specify files or directories to exclude version control, it checks if there is a file named .gitignore directory code repository, if any, rows will read the contents of this file, and each line of the specified file or directory exclude version control.

AndroidStudio when creating the project will automatically help us .gitignore create two files, one in the root directory, a module in the next app.

.gitignore file (automatically generated default configuration) under the root directory:

*.iml 
.gradle 
/local.properties 
/.idea/workspace.xml 
/.idea/libraries 
.DS_Store 
/build 
/captures

.gitignore file (automatically generated default configuration) in the app directory:

/build

If you do not want to add the test file to version control, you can modify the app / .ignore contents of the file are as follows:

/build 
/src/test 
/src/androidTest

After changes to the code, remember to submit, before adding all the files with the add command:

git add.

Then run the commit command to complete the submission:

git commit -m "First commit"

 

View content

Check the revision of the file:

git status

View the contents of files that have changed:

git diff

To review the changes MainActivity.java file:

git diff app/src/main/java/com/example/providertest/MainActivity.java

 

Undo uncommitted changes

As long as the code has not been submitted, all modify the contents can all be undone.

If the file has not been modified to perform add operations, wants to undo the changes, you can use the checkout command:

git checkout app/src/main/java/com/example/providertest/MainActivity.java

If the file has been modified to perform the add operation, you want to undo this change, you need to use the reset command to cancel adding the file, and then undo the checkout command to modify the file:

git checkout app/src/main/java/com/example/providertest/MainActivity.java

 

View submit records

Use the command to view the history log to submit information:

git log

When submitting a lot of records, if we want to see a record where you can specify the record id in the command, and add -1 parameter indicates that we only want to see a record:

git log 1fa390b502a00b82bfc8d84c5ab5e15b8fbf7dac -1

If you want to see the records submitted by this specific modification of what can be added -p parameter in the command:

git log 1fa390b502a00b82bfc8d84c5ab5e15b8fbf7dac -1 -p

 

 

Guess you like

Origin blog.csdn.net/A1344714150/article/details/100161910