2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Table of contents
1. Initialize the workspace (under a certain file path)
2. View the code file status of the current workspace
3. Submit the code files in the workspace to the temporary storage area
4. Submit the code files in the temporary storage area to the local warehouse
5. Compare the difference between the working area and the temporary storage area files
6. Comparison of differences between the staging area and the local warehouse
7. Comparison of differences between workspace and local warehouse
2. Pull the code from the repository
4. View the connected remote warehouse
5. Delete the connection to the remote warehouse
6. Clone and create a new folder without git init initialization
Push the code on idea to the gitee remote repository
Step 1: Create a new repository on gitee
Step 2: Create a new project in idea and let the project generate a git local repository
Step 3: Write code and add it to the staging area and commit it to the local repository
Step 4: Remotely connect to the warehouse
Clone a project from a remote repository
Edit Notes on Pulling Projects
1. Need to modify the address of Maven
2. Need to modify the SDK version
Edit 3. Modify the coded version
We want to create a new branch in the gitee repository now
Edit Then switch the branch of this remote warehouse in idea
Then add and submit, and finally push to the remote warehouse
Git is divided into work area, temporary storage area, local warehouse, local warehouse and temporary storage area are collectively called version library
Click Git Bash Here to enter the command line window
git init;
git status;
git add filename
git add ./ --> Submit all files in the current directory to the temporary storage area
How to know that the file is submitted to the temporary storage area
Using git status
Green means it has been successfully submitted to the staging area, and red means it is still in the working area
git commit -m "commit information"
If it is the first submission
You need to submit your email and username
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git diff read.txt(filename)
Green content is different content
git diff --cached read.txt
No content displayed means the content is the same
git diff HEAD read.txt
1. Roll back to the previous version
git reset --hard HEAD^
2. Roll back to the specified version
git reset --hard version number
git reflog / git log
The red box indicates the current version number. If we want to roll back to the previous version
Roll back to the specified version, using the version number
git branch branch name
git branch
git checkout branch name
Add new content to read.txt of the h1 branch and submit it to the local repository. When you switch back to the master branch, you can find that the newly added content is not displayed. This is because the h1 branch has not been merged into the master branch.
If you want to merge other branches into the main branch, you need to switch to the main branch first.
Note: If you want to merge a branch into the main branch, you need to commit the branch content to the local repository first.
git merge branch name
git branch -d branch name
git remote add origin (connection name) https://gitee.com/-ss_0/hhh1.git (warehouse address)
git pull origin master --allow-unrelated-histories (first time)
git pull subsequent pull
git push -u origin master (first time)
git push Subsequent push
Error:
1. ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/luosu-ss_0/hhh1.git'
Type: git pull --rebase origin master2.fatal: unable to access 'https://gitee.com/luosu-ss_0/hhh1.git/': Could not resolve host: gitee.com
Cause: Network problem
git remote -v
git remote rm origin
git clone repository address
Note: The difference between pulling and cloning
They all get code from remote repositories
difference:
1.git clone: When there is no local version library, the entire version library is cloned from the remote server to the local, which is a process of creating a local version library from scratch.
2.git pull: If there is a local version library, get the latest commit data (if any) from the remote server and merge it to the local
Note: Pull the files from the remote repository first
Enter in the idea terminal
git pull origin master --allow-unrelated-histories
Then you can push it
Push Success
Cloning success
Note: If the push fails, pull the code from the remote repository first.
We can find that the contents of the master branch and the dev1 branch are different. This is because the contents of the dev1 branch have not been merged into the master branch.
So let's switch to the master branch in idea.
Merger Success
Then you can push it