git common command integration

ls -F $(dirname $(dirname $(git --html-path)))/gitweb
echo $(dirname $(dirname $(git --html-path)))/gitweb

-------- ---------------System Configuration--------------------------------- ---
git config --global color.ui true //Enable color support
git config --global core.quotepath false //Support utf-8 encoding
git config --global user.name cuiyaonan
git config --global user.email [email protected]
-----------------------System Configuration-------------------- ----------------


---------------------------------- grep content search -----------------------
git grep "" //document content search in git
-------------- --------------------grep content search---------------------

mkdir -pa/b/ c

git rev-parse --git-dir //Display the location of the .git directory Repository
git rev-parse --show-toplevel //Show workspace root directory
git rev-parse --show-prefix //relative directory relative to workspace
git rev-parse --show-cdup //back to the root of the workspace The depth of display ../../ similar cases
git rev-parse master //display the corresponding commit ID
git rev-parse HEAD //display the corresponding commit ID
git rev-parse refs/heads/master //display the corresponding commit id


--------------------------------config properties file action------------ -------------------------
 git config -e [-global | |--system] //The command to view the config configuration file in git is
 git config core.bare //Display the value of core.bare
 git config core.bare true //Modify the value in
 core.bare git config --unset --global user.name// Delete the value of user.anme in the global variable
--------------------------------config properties file operation------------- -----------------------


-------------------------------------commit commit operation---------- -----------------------------
git commit -a //Delete all modifications and submit them directly. The git add command is passed but the The files that violate the tracking are invalid
 git commit --allow-empty -m "empty commit" //empty commit
git commit --amend --allow-empty --reset-author// amend: patch the commit just now, reset- The author will modify the sitting id synchronously
-------------------------------------commit submission operation- --------------------------------------


------------ -------------------------------Log Operation------------------- -------------------------
 git log --pretty=fuller //Display the most complete log
git log --stat // stat can see File change statistics for each submission git
log --pretty=oneline // Simplified display of logs


git log --pretty=raw --grap <id> //Display the link according to the id, see P85
git log --oneline --decorate -4 //decorate also shows milestones, -4 means to display the first 4
records- -----------------------------------------Log operation------- --------------------------------------



-------------- -------------Current status status command-----------------------------
git status //display Status
git status -s //Condensed display status
git status -s -b //Condensed display content. b means to display the current working branch
---------------------- ---Current status status command




------------------------------------------ -----------------diff comparison command----------------------------- -------
git diff //Compare the workspace and the staging area
git diff HEAD //Compare the workspace and the branch
git diff --cached //Compare the staging area and the repository
------ ------------------------diff comparison command ----------------------- --------------


--------------------------------Relevant file address--------------- ------------------------
.git/config // Configuration file storage
place.git/index //The index file storage place is established and in the object library The corresponding relationship directory tree built by the object entity
HEAD points to refs/heads/master points to master
-------------------------------- Relevant file address ---------------------------------------



-------- ---------------------------checkout command --------------------- -------------
git checkout -- [file name] //All files or specified files in the temporary storage area, replace the files in the workspace. Delete the changes added to the temporary storage area by the workspace
About See P97
-----------------------------------Checkout Command----- -----------------------------


--------------------- -----------------reset command------------------------------- ------
git reset HEAD // The temporary directory tree will be rewritten by the master, and the workspace will not be affected
git reset --hard HEAD^ //The directory tree of the staging area will be rewritten by the master, and the workspace will not be affected (if it has been synchronized with the repository, it will be affected) hard will destroy uncommitted changes in the workspace Use
git reset - with caution -hard master@{2} //Restore the previous 2 steps. See P96 for details
-------------------------------- ------reset command ---------------------------------------




git reflog show master | head -5 //Display the first 5 logs of the non-naked repository


----------------------------------- --About the stash workspace command --------------------------------------- ------
git stash //Save the current work progress All uncommitted changes in the workspace, including the access are gone.
git stash list//Display the saved work progress
git stash pop //From the most recently saved For details on restoring stash in progress,
see P108
git branch //Display the current working branch
--------------------------------- ---About stash workspace commands -------------------------------------------- -------




--------------------------------------------------------- Display according to id Object type, and content command -------------------------------
git cat-flie -t <id> //According to id Display object type
git cat-file -p <id> //Display object content according to id
------------------------------- ----------------Display object type according to id, and content command------------------------- --------------------------------------------------



_ -------------About Milestones------------------------------------ ---
git tag -m 'say bye-bye to all previous practice' old_practice
ls ./git/refs/tags/old_practice
git re-parse old_practice
git describe
Milestone details see P234
------------ --------------------------------------------About Milestones---- ------------------------------------



-------------------------------------------------- ------About deleting files -----------------------------------
git rm --cached < file> // delete files directly from the staging area without making changes in the workspace
git rm file // delete multiple files in the local staging area at the same time separated by spaces
git clean -fd // delete the repository that has not been placed in the workspace The files and directories in
git clean -nd //Display those local files that will be deleted
git add -u //The changes (deletion, modification) of local files do not include additions, all are directly recorded in the staging area, and you can directly commit
-- -------------------------------------------------- ----About deleting files -----------------------------------



-------- -----------------------------About the add command------------------- --------------------------------------
git add -u //Changes to local files (delete , modify) excluding additions, all are recorded directly to the temporary storage area, you can directly commit
gtt add -i //Select according to the number
git add -A //Add all new and modified files to the temporary storage area, You can directly commit
git add . Now all files are added to the staging area
-------------------------------------About the add command---------- --------------------------------------------------------


---- ------------------------------------------Recover previously deleted files--- -------------------------------
git cat-file -p HEAD~1:welcome.txt > welcome.txt // Restore the welcome.txt file in the previous historical version
git show HEAD~1: welcome.txt > welcome.txt //Restore the welcome.txt file in the previous historical version
git checkout HEAD~1 -- welcome.txt //Restore The welcome.txt file in the previous historical version
git add -A //Add all new and modified files to the temporary storage area, you can directly commit
--------------- -------------------------------Recover previously deleted files------------- --------------------



------------------------------ ------------------------------- Display the files in the repository ------------- ---------------------------------
git ls-tree -l HEAD // Display the directory tree l in the repository Indicates the display file size. For the directory tree of the temporary storage area, see P79

git ls-files --with-tree=HEAD^ //Display the file in the previous version in the staging area

git cat-file -p HEAD^:welcome.txt // Display the welcome in the previous historical version in the staging area Content in .txt
--------------------------------------------- ----------------Show files in repository---------------------------- ------------------


-------------------------------- ----------mv move command --------------------------------
git mv welcome.txt readme //Rename welcome.txt to readme. Equivalent to rm + add command set;
------------------------------- -------------mv move command --------------------------------




 git rev-list HEAD|wc -l //Count how many times have been submitted in total


 --------------------------------- ---Repentance --------------------------------------- -------------
git commit --amend -m 'go back b' Modify remarks
 ---------------------------------------- Regret Operation------- --------------------------------------------------

------------------------------------------Reverse Commit----- ---------------------------------------------------------
git revert HEAD |ID //Undo changes to certain operations without changing the commit
----------------------------- ------------Reverse Commit----------------------------------- -----------------



 --------------------------------- -----------Rebase Operation------------------------------------ ----------------
P167 I don't get it
 ----------------------------- --------------Rebase operation --------------------------------- -------------------



------------------------------- --------------Peer-to-peer workspace-------------------------------- -----
git clone /path/to/my/workspace/demo/ /path/to/my/workspace/demo-backup // peer workspace clone
git push /path/to/my/workspace/demo-backup/ //up There is an error in the cloned workspace when there is a workspace push. It must be pulled in the cloned workspace

git rmote -v //The information about the version library can also be viewed in the clone library and can also be viewed in .git/config
--------- ------------------------------------ Peer-to-Peer Workspaces ---------- ---------------------------



----------------------- ---------------------Nude Repository---------------------------- ---------------------
git clone --bare has warehouse address on bare version address //create bare version warehouse
git push bare version address // push in upstream warehouse Data to the bare version address
git --git-dir=naked version address log --oneline //It should not be executed directly in the bare version directory, so add parameters --git-dir
---------- ----------------------------------Naked repository------------- ----------------------------------


-----------------------------------------------Initialize the workspace --------------------------------------
git init initializes the workspace directory, either absolutely or It is a relative directory

git init --bare bare repository address
git push bare repository address master:master //If you push to the bare repository for the first time, you need to add master:master
---------- ------------------------------------Initialize Workspace---------- ---------------------------









author:[email protected]


































Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325823036&siteId=291194637