git常用命令

解决gitignore不生效问题

git rm -r --cached .

git add .

git commit -m 'update .gitignore'

使用命令,本地推送到远程地址

git init # 把项目初始化,相当于在项目的跟目录生成一个 .git 目录

git add . # 把项目的所有文件加入暂存区

git commit -am '项目初始化' # 把项目提交到本地仓库,引号里面的是这次提交的注释,方便以后查看。

git remote add origin xxx.git #为本地的仓库创建一个远程仓库.

git pull --rebase origin master # 把远端仓库中的代码 拉到本地进得合并一下。

git config --global user.name "weiruibai"

git config --global user.password "wrb202305!!"

查看用户名 :git config user.name

查看密码: git config user.password

查看邮箱:git config user.email

查看配置信息: $ git config --list

命令行指令

Git 全局设置
复制代码
git config --global user.name "管理员"
git config --global user.email "admin@example.com"
创建新版本库
复制代码
git clone http://47.106.79.29:9999/root/tangxi-v2-java.git
cd tangxi-v2-java
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 http://xxxxx:54/xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master
已存在的 Git 版本库
复制代码
cd existing_repo
git remote rename origin old-origin
git remote add origin http://xxxxx:54/xxx.git
git push -u origin --all
git push -u origin --tags

如果报403,执行

复制代码
git config --system --unset credential.helper
相关推荐
sunshine22 girl3 小时前
git tag-项目流程
git
imDwAaY16 小时前
6篇文章讲清楚Git:Git 远程协作:fetch、pull、push 到底有什么区别?(3/6)
git·后端
imDwAaY16 小时前
6篇文章讲清楚Git:Git 撤销与恢复:reset、revert、restore 应该怎么选?(4/6)
git
用户733096461230917 小时前
再也不怕手滑丢代码!给 git 高危操作加一层安全校验
git
广白17 小时前
Git Tag 实战:从出包追溯到版本发布
前端·git·面试
Winlifes6 天前
我给 Codex 做了一个 Git 面板:分支树、提交历史和工作区操作
git
郑州光合科技余经理7 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
我命由我123457 天前
Git 推送报错:error: src refspec main does not match any
运维·git·gitee·github·运维开发·学习方法·版本控制
Lcr3s7 天前
Git基础之(0):如何在Ubuntu(Linux)上安装git
git
玄芯散人8 天前
【筑基·058】Git协作工作流:冲突解决和PR流程
git·版本控制·团队协作