http和ssh两种方式git提交:
注意:github使用token进行http提交,不用密码
-
git remote set-url origin https://<your_token>@github.com//.git
-
git config user.password "<your_token>"
1. git status 查看git当前状态
rm -rf .git 删除git
2. git init 初始化git项目
3. git config git配置相关操作
3.1. 查看git当前所有配置的位置
git config --list --show-origin
3.2. 设置用户信息
git config --global user.name "XXX"
git config --global user.email [email protected]
4. git help 查看git命令行使用方法
4.1. git help status
4.2. git status --help
5. git diff 比较文件的差异化
6. git log 查看刚刚提交的版本信息
q 查看信息后退出log
7. git branch 查看分支 同git status
git branch feature/6-6 创建分支
git checkout feature/6-6 切换分支
git checkout -b feature/8-8 新建并切换到分支
(在main分支下,git merge feature/6-6, 即可将6-6合并到main)
git branch -d 分支名 删除分支
git branch -D 分支名 强制删除分支
git push origin --delete 分支名 删除远程分支
8. 首次推送本地的 main 分支到远程的 origin/main 分支时: origin可以任意命名
git push -u origin main
之后只需要执行:
git push 就会默认推送到 origin/main,不需要再指定分支名称。
(或者每次输入:git push origin main)
git push origin main --force 强制推送
9. git pull origin main 拉取远程仓库到本地
10. git remote -v 查看远程仓库链接地址
git remote set-url origin 地址 修改关联的远程仓库origin的地址
=======================================================
【基本流程】 修改文件 -》 暂存区 -》 提交更新
【注意】删除git后要重新添加token密码:git config user.password "<your_token>"
git init 初始化
git add . 提交所有git代码(后面加一个点) 提交到暂存区
git commit -m "feat:project init" 提交到本地数据库中
git remote add origin http地址(SSH地址) 本地关联线上仓库
git push origin main 推送
…or create a new repository on the command line
echo "# managerment-fe" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/Kroo-S/managerment-fe.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin https://github.com/Kroo-S/managerment-fe.git
git branch -M main
git push -u origin main
同一个本地提交不同远程仓库会出现问题:
1. 方法 1:拉取远程变更并合并(推荐)
git pull origin main --rebase
git push origin main
2. 方法 2:强制推送(谨慎使用)
git push origin main --force
3. 方法 3:创建一个合并提交(不使用 rebase)
git pull origin main
git push origin main
=======================================================
生成 Personal Access Token:如果你还没有 GitHub Token,或者不记得你之前生成的,可以按照以下步骤生成一个新的 token:
**· **登录 GitHub,进入 Settings > Developer settings > Personal access tokens > Tokens (classic)。
**· **点击 Generate new token,选择适当的权限(例如 repo)。

-
通过指令修改密码为token git config user.password "<your_token>"
-
把token直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入token
git remote set-url origin https://<your_token>@github.com//.git
<your_token>:换成你自己得到的token :你自己的GitHub的用户名 :你自己的仓库名称
- 输入密码为电脑开机密码

=======================================================
-
git init
-
git config --global user.name "your name"
-
git config --global user.email "[email protected]"
-
ssh-keygen -t rsa -C “[email protected]" 本地生产密钥对

-
git remote add origin [email protected]:mmm-cong/test.git 关联ssh地址
-
...... 待完成......
=======================================================
Q1:VSCode提交代码后,一直转:
Q2:VSCode代码提交
=====================================================================
1. git push -f 强制本地代码覆盖github
- node_module