gitee use tutorial, create project warehouse and upload code

1. About gitee

gitee(Chinese name: Code Cloud, original name Git@OSC) is gita code hosting service launched by Open Source China .
The domestic access GitHubspeed is relatively slow. If you want to host your own code to the cloud, it giteeis a good choice. Huawei's 鸿蒙2.0source code is also on giteetop.

Two, install git

To use it gitee, you need to install the gittool first .
gitTool download: https://git-scm.com/downloads After the
Insert picture description here
installation is complete, enter the version that git --versioncan be viewed on the command line git.
Insert picture description here

The right-click menu will also appear the corresponding menu.
Insert picture description here

Three, log in to gitee

We first in giteethe registered account and log in.
giteeOfficial website: https://gitee.com/

Four, generate SSH public key

Because of our local gitwarehouses and giteetransport between the warehouse through SSHencryption, so we need to configure the SSHpublic key.

Note: Once the gittool is installed , you can use the sshcommand

Open the cmdcommand line and enter the command

ssh-keygen -t rsa -C "[email protected]"

Note: This is [email protected]only the name of the generated sshkey, and does not restrict or require specific naming of a mailbox.

Insert picture description here
Follow the prompts to completeEnter three timesTo generate ssh key.
You can see the id_rsa.pubpath of the public key file we generated : C:\User\Adminstrator/.ssh/id_rsa.pub
enter the directory and open it with a text editor
Insert picture description here
to see the SSHpublic key, which will be used in the following SSH.
Insert picture description here

Five, configure SSH public key

In the giteewebsite click 设置
Insert picture description here
click SSHpublic
Insert picture description here
input public key title, just copy the SSHpublic key to the box, and click OK
Insert picture description here
successful configuration
Insert picture description here

Six, create a project

Click on the top right corner of the +number, the new warehouse
Insert picture description here
below, fill in the information warehouse, and finally click Create to.
Insert picture description here

Seven, clone the warehouse to the local

Click 克隆/下载, then click SSH, assignment gitlink
Insert picture description here
Next, right-click the menu in the blank space of the local directory and click Git Bash Here.
Insert picture description here
Enter git clone 刚刚的git链接as follows

git clone [email protected]:linxinfa/mytest.git

Insert picture description here
After success, the cloned READMEfiles can be seen in the local directory .
Insert picture description here

8. Associate local projects to remote warehouses

Sometimes, we may first have the project file locally, and then giteecreate the warehouse on it.
In this case, the command may be used on the local library git remote addit and giteeassociated with a remote library as follows

git remote add origin git@gitee.com:linxinfa/mytest.git

If you use the command git remote addbeing given:

git remote add origin git@gitee.com:linxinfa/mytest.git
fatal: remote origin already exists.

NOTE The local library has been associated with a name of originthe remote library, this time, you can use git remote -vto view a remote library information:

git remote -v
origin git@gitee.com:linxinfa/mytest.git (fetch)
origin git@gitee.com:linxinfa/mytest.git (push)

We can delete the existing remote library

git remote rm origin

Re-associate remote library

git remote add origin git@gitee.com:linxinfa/mytest.git

Nine, add files

Add a AddFileTest.txtfile locally, as follows, add a file.
Insert picture description here

10. Execute git commands and submit files

Open git, execution gitof add, commit, pushcommand, you can upload local files to a remote repository.
Note: gitSee the end of the article for commonly used commands.
Insert picture description here
Refresh the giteepage, you can see that the local file has been uploaded to ```gitee``
Insert picture description here

11. Delete the warehouse

Click to 管理
Insert picture description here
delete the warehouse and enter the password as prompted
Insert picture description here

Twelve, commonly used git commands

Commonly used gitcommands

git init                        #把当前目录变成git可以管理的仓库
git add readme.txt              #添加一个文件,也可以添加文件夹
git add -A                      #添加全部文件
git rm test.txt                 #删除一个文件,也可以删除文件夹
git commit -a -m "some commit"  #提交修改
git status                      #查看是否还有未提交
git log                         #查看最近日志
git reset --hard HEAD^          #版本回退一个版本
git reset --hard HEAD^^         #版本回退两个版本
git reset --hard HEAD~100       #版本回退多个版本
git remote add origin +地址     #远程仓库的提交(第一次链接)
git push -u origin master       #仓库关联
git push                        #远程仓库的提交(第二次及之后)

More gitcommands can be entered to git --helpview

git --help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone             Clone a repository into a new directory
   init              Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add               Add file contents to the index
   mv                Move or rename a file, a directory, or a symlink
   restore           Restore working tree files
   rm                Remove files from the working tree and from the index
   sparse-checkout   Initialize and modify the sparse-checkout

examine the history and state (see also: git help revisions)
   bisect            Use binary search to find the commit that introduced a bug
   diff              Show changes between commits, commit and working tree, etc
   grep              Print lines matching a pattern
   log               Show commit logs
   show              Show various types of objects
   status            Show the working tree status

grow, mark and tweak your common history
   branch            List, create, or delete branches
   commit            Record changes to the repository
   merge             Join two or more development histories together
   rebase            Reapply commits on top of another base tip
   reset             Reset current HEAD to the specified state
   switch            Switch branches
   tag               Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch             Download objects and refs from another repository
   pull              Fetch from and integrate with another repository or a local branch
   push              Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

Guess you like

Origin blog.csdn.net/linxinfa/article/details/108709835