This is the second day of my participation in the August Text Challenge.More challenges in August
Git version in system:$git version Git version 2.23.0.windowsCopy the code
The installation
Git-x64-for-windows download link github.com/git-for-win…
Git GUI and bash command line operations need to be installed
Git’s bash command line can be used as a Linux shell command line. For example, I use the most here is to SSH to another Linux computer in bash, and then copy the local JAR with SCP command
After git is installed, specify the global configuration
git config --global user.name "your name"
git config --global user.email "your email"
Copy the code
Initialize the Git repository
Create the repository directory and initialize it
cd D:/git
mkdir git-repository
git init
Copy the code
Go to the repository and create the file
Vim readme.md // Enter text information and saveCopy the code
Add the file to the repository
Git add readme.md git add file1.md file2.md file3Copy the code
To submit documents
git commit -m 'input your commit message'
Copy the code
View the warehouse status
Git status // On branch master Changes not stagedfor commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: readme.md
no changes added to commit (use "git add" and/or "git commit -a")
Copy the code
Viewing file Changes
Git diff --git a/readme.md b/readme.md index 488642a.. 1d72fa6 100644 -- a/readme.md +++ b/readme.md @@-1,2 +1,2 @@ -git is a version control system version control system. git is free softwareCopy the code
View information for each git commit
git log
// back info
commit 99187208f290f1cdf749e0302c47ea22161ef30e (HEAD -> master)
Author: 641031 <[email protected]>
Date: Wed Jun 3 17:19:29 2020 +0800
append GPL
commit ae77e40ccf7928bfc64096675fecc403b15516a9
Author: 641031 <[email protected]>
Date: Wed Jun 3 17:11:13 2020 +0800
modify readme
commit 0e8418795c7e5022096f3b6e6ff8e0db33910146
Author: 641031 <[email protected]>
Date: Wed Jun 3 16:53:28 2020 +0800
write a readme file
Copy the code
Add parameters to simplify information output –pretty=oneline
git log --pretty=oneline
// back info
99187208f290f1cdf749e0302c47ea22161ef30e (HEAD -> master) append GPL
ae77e40ccf7928bfc64096675fecc403b15516a9 modify readme
0e8418795c7e5022096f3b6e6ff8e0db33910146 write a readme file
Copy the code
Rollback version
Git reset --hard head~n git reset --hard head~n Git reset --hard commit_id (Version number can be from gitlogGit commit (commit_id)Copy the code
Query git’s automatic record of each of our commands
git reflog
// back info
c9f731a (HEAD -> master) HEAD@{0}: reset: moving to c9f731a
9918720 HEAD@{1}: reset: moving to head^
c9f731a (HEAD -> master) HEAD@{2}: commit: add new line
9918720 HEAD@{3}: commit: append GPL
ae77e40 HEAD@{4}: commit: modify readme
0e84187 HEAD@{5}: commit (initial): write a readme file
Copy the code
Workspace and staging areas in Git
Workspace: Any new actions, such as adding files, deleting files, and modifying file contents, will appear here first
Git add file1 file2… Command, the specified, added file, will appear here
Process: After modifying the file, run the git add command to add the file to the staging area, and finally run the git commit command to commit the file to the Git repository
Git commit commits the first change in the staging area. Git commit commits the first change in the staging area. The second change will not be committed.
Every time you make a change, if you don’t add git to the staging area, it won’t be added to the commit.
Discard changes
file
It has not been put into staging since the changes were made. Now, undoing the changes will return to the same state as the repositoryfile
After it was added to the staging area, it was changed again. Now, undoing the changes will return you to the status after it was added to the staging area
Return the file to its last Git commit or git add state
Git checkout -- file // checkout the latest fileCopy the code
Git reset head
if the changes have already been placed in the staging area, you can use git reset head
to roll back the changes to the specified file from the staging area to the workspace
Delete the file
// Delete git rm file from git repositoryCopy the code
If you simply use rm file to delete the file locally, you can use git checkout — file to checkout the specified file from the git repository
If you delete a file from your Git repository, you can only restore the file by rolling back the repository
git rm test.md
git reset --hard head
Copy the code
Remote warehouse
Create nativessh key
ssh-keygen -t rsa -C "[email protected]"
Copy the code
Press Enter all the way to use the default Settings
Finally, a.ssh folder is generated in the current user directory, such as C :/user/wangbin1/.ssh
Add SSH to Github
Log in to Github, go to Settings, and find the SSH option
Step 1
Step 2
Step 3 enter the contents of the id_rsa.pub file in the.ssh directory in key
Client tools
After all, the command line should be used by the big guy fly, like me this just entry, the basic will be very not used to, and, graphical operation is not sweet?
Recommend a few common graphical tools:
git GUI
It is provided by default when you install the software
Github Desktop
Features include a nifty partitioning method that makes it easy to check for branches with pull requests, you can check for differences between images and code blocks, and you can even manage by dragging and dropping items from your application.
Connection: central.github.com/deployments…
Fork
Fork is a free advanced GUI Git client for Mac and Windows that focuses on speed, user-friendliness, and efficiency. Features include theme layouts with quick action buttons, built-in merge conflict helpers and parsers, warehouse managers, GitHub notifications and more.
The bad news, though, is there a fee?
Links: git-fork.com/update/win/…