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
相关推荐
恋喵大鲤鱼6 小时前
git checkout
git·git checkout
知识汲取者8 小时前
Git撤销操作全解析:revert、undo与drop commit的区别与应用
git
cxxx1713 小时前
【同步Overleaf, Github】
git·overleaf
染翰14 小时前
Linux root用户安装配置Git
linux·git·后端
老虎海子14 小时前
从零手搓一个 AI 编程助手:Mini Claude Code 完全指南
人工智能·git·vscode·python·github
Cat_Rocky15 小时前
CICD-Git简单学习 操作流程后续补
git·学习
存在的五月雨15 小时前
Git的操作
git
丶Darling.15 小时前
Git 初学者使用手册
git
乐于分享的阿乐17 小时前
Git下载安装与零基础使用完整教程
git
东北甜妹17 小时前
DevOps 和 Git,Gitlab
git·gitlab·devops