Day 02 Gitee warehouse basic operation

Day 02 Gitee warehouse basic operation

1. Basic warehouse management

Initialize a Git repository (take /home/gitee/testfolder as an example)

$ cd /home/gitee/test    #进入git文件夹
$ git init               #初始化一个Git仓库

Add files to Git's staging area

$ git add "readme.txt" 
$ git add .  # 将当前目录下所有的文件添加到暂存区

Note: Use git add -Aor git add .to submit all changes in the current warehouse.

Check the current file submission status of the warehouse (A: successful submission; AM: the file has been changed after being added to the cache)

$ git status -s

Submit the version from Git's staging area to the warehouse, -mafter the parameter is the remarks of the current submission

$ git commit -m "1.0.0"

Push and upload local Git warehouse information to the server

$ git push https://gitee.com/***/test.git

View the log submitted by git

$ git log

2. Remote warehouse management

Modify warehouse name

Generally speaking, by default, when performing clone or other operations, the warehouse name is origin. If we want to change the name for him, for example, I don’t like the name of origin and want to change it to oschina, then it must be in the warehouse directory. Excuting an order:

git remote rename origin oschina

In this way, the name of your remote warehouse is changed to oschina. Similarly, the command to be executed when pushing is no longer git push origin master but git push oschina master. The same is true for pulling

Add a warehouse

When not performing the cloning operation, if you want to add a remote warehouse to the local warehouse, you can execute

git remote add origin  仓库地址

Note: 1. Origin is the alias of your warehouse. You can change it at will, but please be sure not to conflict with the existing warehouse alias. 2. The warehouse address generally supports the http/https/ssh/git protocol. Please do not add other protocol addresses.

View the remote warehouse address corresponding to the current warehouse

git remote -v

This command can display the warehouse name and the corresponding warehouse address that you have added to the current warehouse. Generally speaking, there will be two identical records, fetch and push. Fetch is used to synchronize push from remote Push to remote

Modify the remote warehouse address corresponding to the warehouse

git remote set-url origin 仓库地址

Guess you like

Origin blog.csdn.net/A1L__/article/details/111874422