Article Directory
-
-
- 1. About gitee
- Two, install git
- Three, log in to gitee
- Four, generate SSH public key
- Five, configure SSH public key
- Six, create a project
- Seven, clone the warehouse to the local
- 8. Associate local projects to remote warehouses
- Nine, add files
- 10. Execute git commands and submit files
- 11. Delete the warehouse
- Twelve, commonly used git commands
-
1. About gitee
gitee
(Chinese name: Code Cloud, original name Git@OSC
) is git
a code hosting service launched by Open Source China .
The domestic access GitHub
speed is relatively slow. If you want to host your own code to the cloud, it gitee
is a good choice. Huawei's 鸿蒙2.0
source code is also on gitee
top.
Two, install git
To use it gitee
, you need to install the git
tool first .
git
Tool download: https://git-scm.com/downloads After the
installation is complete, enter the version that git --version
can be viewed on the command line git
.
The right-click menu will also appear the corresponding menu.
Three, log in to gitee
We first in gitee
the registered account and log in.
gitee
Official website: https://gitee.com/
Four, generate SSH public key
Because of our local git
warehouses and gitee
transport between the warehouse through SSH
encryption, so we need to configure the SSH
public key.
Note: Once the
git
tool is installed , you can use thessh
command
Open the cmd
command 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.
Follow the prompts to completeEnter three timesTo generate ssh key
.
You can see the id_rsa.pub
path of the public key file we generated : C:\User\Adminstrator/.ssh/id_rsa.pub
enter the directory and open it with a text editor
to see the SSH
public key, which will be used in the following SSH
.
Five, configure SSH public key
In the gitee
website click 设置
click SSH
public
input public key title, just copy the SSH
public key to the box, and click OK
successful configuration
Six, create a project
Click on the top right corner of the +
number, the new warehouse
below, fill in the information warehouse, and finally click Create to.
Seven, clone the warehouse to the local
Click 克隆/下载
, then click SSH
, assignment git
link
Next, right-click the menu in the blank space of the local directory and click Git Bash Here
.
Enter git clone 刚刚的git链接
as follows
git clone [email protected]:linxinfa/mytest.git
After success, the cloned README
files can be seen in the local directory .
8. Associate local projects to remote warehouses
Sometimes, we may first have the project file locally, and then gitee
create the warehouse on it.
In this case, the command may be used on the local library git remote add
it and gitee
associated with a remote library as follows
git remote add origin git@gitee.com:linxinfa/mytest.git
If you use the command git remote add
being 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 origin
the remote library, this time, you can use git remote -v
to 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.txt
file locally, as follows, add a file.
10. Execute git commands and submit files
Open git
, execution git
of add
, commit
, push
command, you can upload local files to a remote repository.
Note: git
See the end of the article for commonly used commands.
Refresh the gitee
page, you can see that the local file has been uploaded to ```gitee``
11. Delete the warehouse
Click to 管理
delete the warehouse and enter the password as prompted
Twelve, commonly used git commands
Commonly used git
commands
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 git
commands can be entered to git --help
view
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.