Put the project file into the gitee repository and the git command

Place local project files into warehouse

  1. Create a new warehouse in gitee, enter the warehouse name and click create
  2. After creating a warehouse, there are steps to follow directly

    I made a low-level mistake: I thought the warehouse in the screenshot refers to the newly built warehouse,
    Follow the steps of the existing warehouse and report an error

    But in fact, the warehouse here refers to the local warehouse. My project file is written by myself and no local warehouse is established, so I need to execute the command according to the steps of creating git warehouse. Then put the local project into the warehouse.

Note: the default name of the remote warehouse is origin
!! In order to avoid various inexplicable problems when using Windows system, please ensure that the directory name (including the parent directory) does not contain Chinese.

After the warehouse is built, some commonly used git commands

Put a file in Git's local repository

git add . // Add content from the working directory to the staging area.
git commit -m "wrote a readme file" // Tell Git to submit the file to the warehouse: - m, and then enter the description of this submission
git status //To view workspace status
git push  //Update the downloaded file back
git pull   //Download the updated files from your partner
git  push origin master // Push the latest changes of the local master branch to Gitee

If git pull prompts no tracking information, it indicates that the link relationship between the local branch and the remote branch has not been created. Use the command

git branch --set-upstream-to <branch-name> origin/<branch-name>

Other commands and functions

The pwd command displays the current directory

pwd 

Use the following command to turn the current directory into a warehouse that git can manage: after using this command, a git folder will be automatically generated in this directory

git init

View the modified content: display the latest to farthest submission logs. Add the – pretty = online parameter to make the directory clearer. git log. We can see three submissions. The latest one is append GPL, the last one is add distributed, and the earliest one is write a readme file.

git diff

Fallback to the previous version: the current version is represented by HEAD, and the previous version is HEAD^

 git reset --hard HEAD^ 

Specifies to go back to a future version

git reset --hard 1094a

Used to record every command you give

git reflog

Discard changes in the workspace: undo the changes in the staging area and put it back in the workspace

git checkout -- file name.suffix  --It's important, No--,It becomes the "switch to another branch" command

Push the latest changes of the local master branch to Gitee

 git push origin master

This operation can pull the latest file submitted to the version library to the staging area, and this operation does not affect the workspace

git reset HEAD <file>
Example: git reset HEAD readme.txt 

Delete file: delete the file manually first, and then use

git rm <file>
git add<file>  The effect is the same.

View remote library information

git remote -v

If the address is written incorrectly when adding, or you just want to delete the remote library, you can use

git remote rm <name>

Push all contents of the master branch for the first time

git push -u origin master

Merge the specified branch to the current branch

git merge

View all branches

git branch 

Create branch

git branch <name>

Directly switch to the existing master branch

 git switch master
 git checkout master

Create the dev branch and switch to the dev branch

git checkout -b dev
git switch -c dev

Delete dev branch

git branch -d dev

View branch merge graph

git log --graph

Forcibly disable the Fast forward mode (in this mode, the branch information will be lost after deleting the branch)

git merge --no-ff -m "merge with no-ff" dev

"Store" the current work site and continue to work after restoring the site in the future

git stash

View the job site

git stash list

Restore stored work site

git stash apply Recovery, but after recovery, stash The content is not deleted, you need to use git stash drop To delete
git stash pop,While recovering stash The content has also been deleted

Label branches

git tag v1.0

View all labels

git tag

View label information

git show <tagname>

Tag with description - a indicates tag name - m indicates description information

git tag -a v0.1 -m "version 0.1 released" 1094adb
 Note: labels are always associated with a commit a hook. If this commit Both appear in master Branch, appear again in dev Branch, so you can see this tag on the two branches.

delete a tap

git tag -d v0.1

Push a tag to remote

git push origin((default library name) v1.0

Push all local tags that have not been pushed to the remote at one time

git push origin --tags

Create a new branch in gitee

git push -u origin gqx_dev

Tags: Javascript Front-end git

Posted on Sat, 20 Nov 2021 20:58:48 -0500 by mariaak83