//Create username and email git config --global user.name "richard" git config --global user.email "[email protected]"、 //Check git config --global user.name git config --global user.email git init //create code repository ls -al //There will be a hidden .git file to view hidden files. If you delete the warehouse, you only need to delete this file. //add modified file git add build.gradle //add modified folder git add app //Add all files in the current directory git add . //submit git commit -m "fitst commit" // ignore the file Git has a .gitigore file that can be configured to ignore files. When androidstudio creates a project, it automatically creates .gitigore, one in the root directory and one in the APP directory. // check the status of the change git status // view the modified content git diff //Reverse uncommitted modifications (applicable without executing add) git checkout app/src/main/java/com/example/providers/MainActivity.java //If it has been added, how to revoke git reset HEAD app/src/main/java/com/example/providers/MainActivity.java git checkout HEAD app/src/main/java/com/example/providers/MainActivity.java git log //View the commit record git log commit record id -1 //just want to see one piece of data git log commit record id -1 -p //Want to see what was submitted // branch usage git branch version1.0 //Create branch git branch // view all branches //The bug on the branch is fixed and needs to be merged into the main branch git branch master git merge version1.0 // branch delete git branch -d version1.0 //Remotely git clone https://github.com.richard/test.git //Download the project to the local git push origin master //Submit remote, origin remote, master submitted branch // Synchronize remote to local commands fetch, pull, fetch syntax rules are similar to push git fetch origin master // Synchronize the remote to the local, but the synchronized code will not be merged into any branch, but exists on the origin/master branch, //At this time, you can use the diff command to see what has been modified: git diff origin/master, //Afterwards, merge the changes on the origin/master branch to the main branch through merge: git merge origin/master //Pull is equivalent to the merger of fetch and merge git pull origin master //How to host the project to github Create a warehouse aaa on github 1. Select android.gitigore 2. Select apache 2.0 3. 生成 .gitigore LICENSE README.md 4. Copy the github repository address 5. Enter the project root directory and execute git clone github warehouse address 6. At this time, copy all files in aaa (including .git, if you can't see all files, use ls -al to view all files) to the previous level and delete aaa 7.git add . 8.git commit -m "fist commit" 9. git push origin master requires authentication at this point 10. Refresh the github homepage, you can see the submitted project
Basic usage of git command line
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325602401&siteId=291194637
Recommended
Ranking