finally! I started to learn how to use Git!

1. First download git for windows

Is there any magic that can't open Git for Windows  ?

A brief guide to git can be downloaded by clicking here

2. Principles of Git

When this appears, the installation is complete!

Git can store any folder and make it easy for you to retrieve the file status of any date!

 Fundamental:

The workspace is also your total project folder. Let’s start the actual combat!

3. Push any folder to the staging area in sequence

Find any of your project folders and right-click!

Enter: git init to initialize the repository to create a new git repository. 

 I created a readme.txt file! Then enter the command:

git add -A 

All files in the total directory will be uploaded to the temporary library. You can use git status to view the current warehouse status.

git status

4. Push any folder to the local warehouse in sequence

git commit -m "a name"

git commit -m "提交信息" Submit the file to the repository. Submit information enclosed in English double quotes.

5. Connect to the remote warehouse, one project corresponds to one warehouse, you only need to connect once


Step 1: Install Git First, you need to install Git on your computer. You can download the installer from the Git official website and follow the prompts to install it.
Step 2: Create a local repository. Open the folder where you want to create a repository and create a new folder in it as your local repository. In this repository you will save your code files.
Step 3: Initialize the Git repository. In the root directory of the local repository, open the command line interface (for Windows users, please open Git Bash or command prompt) and run the following command to initialize the Git repository: css copy git init This will create
a
local
repository
. A folder named ".git" that contains all the configuration and metadata required by Git.
Step 4: Add files to the Git repository Add your code files to the Git repository. Use the following command to add files to the staging area:
shell
copy
git add <filename>
If you want to add all the files in the entire directory, you can use the following command:
shell
copy
git add .
Step 5: Commit changes Use the following command to commit the staging area Change the files in the storage area to the local warehouse:
sql
copy
git commit -m "First submission"
The text in quotation marks can be a specific description of your submission, which is used to record the information of this submission.
Step 6: Connect to the remote repository First, you need to get the repository's SSH address (also known as the clone address) on the remote repository's page. Copy this address.
Then, in the root directory of the local repository, run the following command to connect the local repository to the remote repository:
bash
copy
git remote add origin <SSH address of the remote repository>
For example, if the SSH address of your remote repository is "ssh://[email protected]/user/repo.git", run the following command:
bash
copy
git remote add origin ssh://[email protected]/user/repo.git
Step 7: Push files to the remote repository Finally, use the following command to push your local commits to the remote repository:
perl
copy
git push -u origin master
in In the above command, "origin" is the alias of the remote repository you defined in step 6, and "master" is the master branch of the remote repository. If your remote repository uses a different branch (such as "main"), change the branch name accordingly.
If you have set up a global Git username and email address, and set the corresponding configuration in the local warehouse, Git will push your commit information to the remote warehouse. If this information has not been set up yet, run the following commands to set it up:
sql
copy
git config --global user.name "your username"
git config --global user.
email "your email address" Now you have successfully connected your local repository to the remote repository and pushed your files to the remote repository. congratulations! If you need further operations, such as pulling updates from the remote repository or switching branches, please continue to ask me questions.

6. Push any folder to the remote warehouse in sequence

6. Retrieve files at a certain point in time

Reference: https://www.cnblogs.com/schaepher/p/5561193.html 

Guess you like

Origin blog.csdn.net/leoysq/article/details/133356879