Table of Contents
1. Version Controller Method
1.1 Actual scenario
1.2 Version control method
3.4 Using git in IDEA
4. Basic operation instructions
Home Development Tools git Git tutorial notes organization (summary sharing)

Git tutorial notes organization (summary sharing)

Mar 17, 2022 pm 06:18 PM
git

This article brings you relevant knowledge about Git, mainly the compilation of git tutorial notes, including version controller methods, installation, basic operations and operating instructions, etc. I hope Helpful to everyone.

Git tutorial notes organization (summary sharing)

Recommended study: "Git Tutorial"

1. Version Controller Method

1.1 Actual scenario

Backup code restoration collaborative development traceability code issues

1.2 Version control method

  1. Centralized version Control tools SVN and CVS
    Everyone downloads the code from the central server, and submits the modifications to the central server.
  2. Distributed version control tool git
    Everyone’s computer has a complete library, and each other can see each other’s changes.
    Git tutorial notes organization (summary sharing)
##2. Installation

    Explanation:
  1. · Git GUI: The graphical interface tool provided by Git
    · Git Bash: Git The command line tool provided
  2. After installation, set up the email first (the email identifies different people):
  3. Open Git Bash—
    Set the person
    git config --global user.name "name " Set up email
    git config --global user.email "email"
  4. can be viewed through
  5. git config --global user.name Whether the setting is successful
3. Start the operation

3.1 Create a local warehouse

1) Create an empty directory as a local Git warehouse

2) Enter this directory and right-click to open the Git bash window
3) Execute the command
git init 4) After the creation is successful, you can see the hidden .git directory under the folder
You can view the basic operations of
Part 4 later

3.2 Branches

Almost all version controls support branches. Everyone has an independent branch, and development does not affect each other. When finished, merge them together. HEAD points to the current branch, and modifications will only change the contents of the current branch.


git branch View branch
git branch nameCreate name branch
git checkout branch name Switch branch git checkout -b Branch name Create and switch
git merge Branch name 1 Merge branch Branch 1 merges with the current branch If
different branches conflict: they will not be merged automatically , storing different versions of information in files requires manual selection
git branch -d nameDelete name branch-DForce deletion

3.3 Git remote Warehouse

Commonly used are GitHub, Code Cloud, and GitLab (commonly used by enterprises). The course uses Code Cloud as an example.

1) Open the gitee web page to log in - create a new warehouse -
2) Configure the SSH public key:

    Enter
  1. ssh-keygen -t rsa in bash (continuous Press Enter to automatically overwrite if the public key already exists)
  2. cat ~/.ssh/id_rsa.pubGet the public key - copy the output public key - open gitee's user-settings-SSH Public key
  3. Verify whether the configuration is successful:
  4. ssh -T git@gitee.com
3) Connect to the local warehouse

    Open the warehouse created on gitee and copy SSH (the address of the remote warehouse)
  1. In bash
  2. git remote add name (the name you set) ssh address Note that you need to before this git init
  3. Check whether the configuration is successful
  4. git remote It will be successful if the name you set appears
  5. Local code upload
  6. git push [local branch name] :[Remote branch name] Note that you must submit it in the local warehouse before doing this The complete code is
    git push [-f] [--set-upstream][Remote name] [Local branch name]: [remote branch name] [-f]: Force overwriting of remote code
    [–set-upstream] means establishing an association between local and remote branches
    Remote branch If the name is the same as the local
    , it can be omitted: [remote branch name] If both are associated , then [local branch name] can be omitted: [remote branch name]
  7. 4) Other operations
  1. Clone from the remote warehousegit clone <warehouse path> [Local path]</warehouse>
  2. Fetch from the remote warehousegit fetch [remote name] [ branch name]
    will capture the updates in the warehouse locally and will not merge them. If the remote name and branch name are not specified, all branches will be fetched and the current branch will be updated. If you need to merge, you needgit merge [remote name]
  3. pull commandgit pull [remote name] [branch name] That is, grab and merge
  4. Resolve Merge Conflicts
    After AB is cloned from the remote end, A will modify it locally and then push it to the remote end. After B modifies the same content of the same file locally and wants to pull it from the remote warehouse, there will be a merge conflict. , which is the same as the way to resolve conflicts between different local branches.

3.4 Using git in IDEA

I haven’t used idea

4. Basic operation instructions

Created before Except for the .git file, other files in the folder are our working directory. Modify files (add, delete, update) in the working directory. The status of these modifications will change as we execute Git commands
git add: Create a new file from scratch (Not tracked) or modify an existing file (not staged) Use the git add command to save the file to the staging area. (Workspace - Staging area)
git commit: The staging area enters the warehouse and generates a commit record. (Staging area - warehouse) git commit -m "Comment content"
git status: View the status of the working directory and staging area
git log : View the history of commits

  • –all Display all branches
  • –pretty=oneline Display commit information as one line
  • –abbrev-commit Make the output The commit is shorter
  • -graph Display with graph

git reset --hard commitID: Version rollback
You can use git -log or git log command to view the commitID
touch .gitignore Add the file name that you do not want to participate in the update, and you can no longer participate in the warehouse management

Recommended learning: "Git Learning Tutorial

The above is the detailed content of Git tutorial notes organization (summary sharing). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1254
29
C# Tutorial
1228
24
How to update code in git How to update code in git Apr 17, 2025 pm 04:45 PM

Steps to update git code: Check out code: git clone https://github.com/username/repo.git Get the latest changes: git fetch merge changes: git merge origin/master push changes (optional): git push origin master

How to download git projects to local How to download git projects to local Apr 17, 2025 pm 04:36 PM

To download projects locally via Git, follow these steps: Install Git. Navigate to the project directory. cloning the remote repository using the following command: git clone https://github.com/username/repository-name.git

How to merge code in git How to merge code in git Apr 17, 2025 pm 04:39 PM

Git code merge process: Pull the latest changes to avoid conflicts. Switch to the branch you want to merge. Initiate a merge, specifying the branch to merge. Resolve merge conflicts (if any). Staging and commit merge, providing commit message.

What to do if the git download is not active What to do if the git download is not active Apr 17, 2025 pm 04:54 PM

Resolve: When Git download speed is slow, you can take the following steps: Check the network connection and try to switch the connection method. Optimize Git configuration: Increase the POST buffer size (git config --global http.postBuffer 524288000), and reduce the low-speed limit (git config --global http.lowSpeedLimit 1000). Use a Git proxy (such as git-proxy or git-lfs-proxy). Try using a different Git client (such as Sourcetree or Github Desktop). Check for fire protection

How to solve the efficient search problem in PHP projects? Typesense helps you achieve it! How to solve the efficient search problem in PHP projects? Typesense helps you achieve it! Apr 17, 2025 pm 08:15 PM

When developing an e-commerce website, I encountered a difficult problem: How to achieve efficient search functions in large amounts of product data? Traditional database searches are inefficient and have poor user experience. After some research, I discovered the search engine Typesense and solved this problem through its official PHP client typesense/typesense-php, which greatly improved the search performance.

How to use git commit How to use git commit Apr 17, 2025 pm 03:57 PM

Git Commit is a command that records file changes to a Git repository to save a snapshot of the current state of the project. How to use it is as follows: Add changes to the temporary storage area Write a concise and informative submission message to save and exit the submission message to complete the submission optionally: Add a signature for the submission Use git log to view the submission content

How to update local code in git How to update local code in git Apr 17, 2025 pm 04:48 PM

How to update local Git code? Use git fetch to pull the latest changes from the remote repository. Merge remote changes to the local branch using git merge origin/&lt;remote branch name&gt;. Resolve conflicts arising from mergers. Use git commit -m "Merge branch &lt;Remote branch name&gt;" to submit merge changes and apply updates.

How to delete a repository by git How to delete a repository by git Apr 17, 2025 pm 04:03 PM

To delete a Git repository, follow these steps: Confirm the repository you want to delete. Local deletion of repository: Use the rm -rf command to delete its folder. Remotely delete a warehouse: Navigate to the warehouse settings, find the "Delete Warehouse" option, and confirm the operation.

See all articles