0

#git新建仓库后的常用操作

 2 years ago
source link: https://xmanyou.com/gitlab-common-operation-for-new-repo/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
17 November 2021 / gitlab

#git新建仓库后的常用操作

在gitlab上新建仓库以后,需要在客户端进行一些的常用操作有:

Git 全局设置

设置你的用户名和邮箱:

git config --global user.name "你的用户名"
git config --global user.email "你的账号邮箱"

之后,可以根据本地的情况,来选择不同的操作:

1. 创建一个新仓库

如果本地没有新仓库任何文件,可以通过以下命令创建一个:

git clone <git仓库的地址>
cd <新仓库的文件夹名>
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

2. 推送现有文件夹

如果你之前已经在本地进行了一些开发工作,但是还没有关联到任何的git仓库,现在想把它加入该仓库,则可以:

cd <本地已有的文件夹>
git init
git remote add origin <git仓库的地址>
git add .
git commit -m "Initial commit"
git push -u origin master

3. 推送现有的 Git 仓库

如果你之前已经在本地进行了一些开发工作,而且已经关联到一个旧的git仓库,现在想把它加入新仓库,则可以:

cd <本地已有的文件夹>
git remote rename origin old-origin
git remote add origin <git仓库的地址>
git push -u origin --all
git push -u origin --tags

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK