Hello everyone, my name is Sun Bujian 1208, welcome to follow my blog.
1. Understand the Git
2.Git local basic operations: connect to Github to commit updates.
3. Git operation in IDEA: connect to Github to commit updates.
The concept of versioning
Revision Control (Revision Control) is a software engineering technique used to manage the history of changes we have made to a file, directory, or project during development. It is easy to view the history of changes and back up to restore the previous version.
Simply put, it is a technology for managing collaborative development projects.
Git is a version control tool.
Addendum: Common version control tools
Git
SVN (Subversion)
CVS (Concurrent Versions System)
VSS (Microsoft Visual SourceSafe)
TFS (Team Foundation Server)
Visual Studio Online
Version Control products are numerous (Perforce, Rational ClearCase, RCS (GNU Revision Control System), Serena) Dimention, SVK, BitKeeper, Monotone, Bazaar, Mercurial, SourceGear Vault), now the most influential and widely used ones are Git and SVN.
Version control classification
Local version control
Centralized version control SVN
The SVN is a centralized version control system, and the version library is centrally located on the central server. When working, you use your own computer. Therefore, you need to get the latest version from the central server first. The centralized version control system must be connected to the network to work, which requires a high network bandwidth.
Distributed version control of Git
Git is a distributed version control system. There is no central server. Everyone’s computer is a complete version library. For example, if you change file A on your computer and someone else changes file A on your computer, you only need to push your changes to each other, and then you can see each other’s changes. Git can see directly what code and files have been updated!
The Git download
Open the Git official website and download the version of the git operating system.
After installation, there are three programs under Git menu
Git Bash: Unix and Linux style command line, most used, most recommended
Git CMD: A Windows-based command line
Git GUI: It is not recommended for beginners to use Git. Try to get familiar with common commands first
Attached: command line Git basic operations
Git commits/updates code
To understand:
- Workspaces, staging areas, and local repositories are all on your computer. Github is the remote repository
- Workspace can be provisionally understood as IDEA
- The staging area can now be understood as a cache
- Git commit consists of two phases: commit to the local repository, and then commit to Github.
- We only need to focus on the local warehouse, remote warehouse, other is not very important
You can use Git as an example
1. Create repository Repositorys
1. Create folder Repositorys
2. Create folder demo under Repositorys
3. Create a workspace using Git
- Git statement: git init
- Git GUI to select
- Use tortoise “Create repository here”
4. The. Git file is available in the workspace after creation
2. Add, delete, modify and check in the local warehouse
File operations in the local repository are performed within the workspace
1. Add files to the local repository. The files must be placed in the workspace
2. Add the file to the staging area (a step to do when the file is first committed)
3. Submit the file to the local repository
- Commit to local repository branch “master”
- Fill in the log
4. View the contents of the local repository
- That is to view the Repository browser
5. After modifying the file, submit it to the branch master of the local repository and enter a log
6. View logs
7. Delete files
- After deleting by mistake, you can use the local repository to restore to the workspace.
- Deleting a file and committing it to a local repository is a real delete.
Create a remote repository on Git Hub
1. Github ->Start a project->Create a new repository
Iv. Push to remote Warehouse
Two communication protocols: HTTPS SSH
The SSH protocol is very secure. It provides key-based security authentication
SSH Connection to GitHub and SSH key configuration on GitHub
HTTPS
Use HTPPS to push the local repository to the remote repository
1. Copy the HTTPS of the remote repository
2. Right-click Git synchronization -> Manage -> Origin
3. Paste the HTTPS copy to the URL-> Add/Save
4. Push (first time: you need to enter your Github user name and password)
5. Clone remote warehouse to local (Clone)
1.Clone or download the URL
2. Right-click Git clone in the local repository, enter the URL and pull it
Use Git in IDEA
Configure Git in IDEA
- File — > Settings Open the Settings window and find the Git option under Version Control (set it to your own path).
- Test
Create a local repository
-
VCS — >Import into Version Control — >Create Git Repository
-
Choose the location of your local warehouse
3. Operation in IDEA
4. Push to remote warehouse (Push) and Clone remote warehouse to local (Clone)
1. Push to remote warehouse (Push)
- VCS->Git->Push->Define remote
- Fill in the URL
- Push (you need to enter your Github username and password for the first time)
2. Clone the remote repository to the local server (Clone)
- Enter the URL to select the local storage location
- Wait until the clone is loaded
That’s all for this episode. If it helped you, thanks for liking it!