git初始化操作

初始化操作

全局配置

git config --global user.name "xxx"
git config --global user.email "xxx@xx.com"

创建新仓库

git clone git@gitlab.bl.com:XXX/xxx.git
cd cdpstream
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

推送已存在的文件夹

cd existing_folder
git init
git remote add origin git@gitlab.bl.com:XXX/xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master

注意:在项目中最好先创建.gitignore,其中把开发工具自身等对其它人员无用的配置文件或文件夹忽略

/bak
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

.idea
*.iml

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
.log
jars
.mvn

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/

### VS Code ###
.vscode/

推送已存在Git仓库

cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.bl.com:XXX/xxx.git
git push -u origin --all
git push -u origin --tags

常用操作

可看当前状态

# git status

On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   .gitignore
        new file:   .idea/.gitignore

从stage中删除

git rm --cached <file>

配置

git config命令的–global参数,表示你这台机器上所有的Git仓库都会使用这个配置,也可以对某个仓库指定不同的用户名和Email地址。

查看配置信息

$ git config --list

查看用户名、密码、邮箱

$ git config user.name
$ git config user.password
$ git config user.email

设置

用户名、密码、邮箱

$ git config user.name "sven"
$ git config user.password "xxx"
$ git config user.email "xxx@xxx"

用户名、密码、邮箱

$ git config --global user.name 用户命
$ git config --global user.name freedom
$ git config --global user.password 密码
$ git config --global user.password abc0506abc
$ git config --global user.password 邮箱
$ git config --global user.email "xxx@xxx"

修改用户名、密码、邮箱的配置

$ git config user.name "sven"

修改全局配置用户名、密码、邮箱

$ git config --global user.name "sven"


Command line instructions
You can also upload existing files from your computer using the instructions below.

Git global setup
git config --global user.name "魏山巍"
git config --global user.email "shanwei.wei@bl.com"

Create a new repository

git clone git@gitlab.bl.com:CDP/cdp-elastic.git
cd cdp-elastic
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main

Push an existing folder

cd existing_folder
git init --initial-branch=main
git remote add origin git@gitlab.bl.com:CDP/cdp-elastic.git
git add .
git commit -m "Initial commit"
git push -u origin main

Push an existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.bl.com:CDP/cdp-elastic.git
git push -u origin --all
git push -u origin --tags
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大怀特

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值