git| gitlab命令行操作
GitLab
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master) $ mkdir ~/.ssh mkdir: cannot create directory ‘/c/Users/Administrator/.ssh’: File exi sts Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master) $ cd ~/.ssh
Administrator@PC201803221826 MINGW64 ~/.ssh
$ git config --global user.name "XX"
Administrator@PC201803221826 MINGW64 ~/.ssh
$ git config --global user.email "XX@lifeat.cn"
Administrator@PC201803221826 MINGW64 ~/.ssh
$ ssh-keygen -t rsa -C "XX@lifeat.cn"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:VMyQbkP6olb8oXXvfwsu/L35P5NTnw7SEhh1OEIvuHM 190438@lifeat.cn
The key's randomart image is:
+---[RSA 2048]----+
| o*.... |
| +o=o. |
| =.o... |
| ..= + |
| . =SE . |
| + * . o .|
| o = o.+ + =|
| o . . o= +*+|
| . .++oB@|
+----[SHA256]-----+
Administrator@PC201803221826 MINGW64 ~/.ssh
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git config --global user.name "XX"
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git config --global user.email "190438@lifeat.cn"
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git init
Reinitialized existing Git repository in F:/BI/bi/脚本/.git/
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git remote add origin ssh://git@git.hopson.io:65508/data-center/hopsonone/ dp-data-analysis/easylife_data_analysis.git
fatal: remote origin already exists.
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git remote add o ssh://git@git.hopson.io:65508/data-center/hopsonone/dp-da ta-analysis/easylife_data_analysis.git
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git add dws_broker_reward.sh dws_should_solid_knot_fc_ac.sh dws_total_amou nt.sh
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git commit -m "remote-shell"
[master (root-commit) 3730f82] remote-shell
warning: LF will be replaced by CRLF in dws_broker_reward.sh.
The file will have its original line endings in your working directory.
3 files changed, 1170 insertions(+)
create mode 100644 dws_broker_reward.sh
create mode 100644 dws_should_solid_knot_fc_ac.sh
create mode 100644 dws_total_amount.sh
Administrator@PC201803221826 MINGW64 /f/BI/bi/脚本 (master)
$ git push -u o master
The authenticity of host '[git.hopson.io]:65508 ([47.94.203.190]:65508)' can 't be established.
ECDSA key fingerprint is SHA256:CRCRBb4FwTO0TNfqlBA6wBvRW+OKU4pc2mULCqbxMmk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[git.hopson.io]:65508,[47.94.203.190]:65508' (EC DSA) to the list of known hosts.
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 7.26 KiB | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To ssh://git@git.hopson.io:65508/data-center/hopsonone/dp-data-analysis/easy life_data_analysis.git
* [new branch] master -> master
Branch master set up to track remote branch master from o.
查看当前git的用户名和邮箱:
$ git config user.name $ git config user.email
修改用户名和邮箱地址:
$ git config --global user.name "username"
$ git config --global user.email "email"
如何在 GitHub.com 上删除某个 Repository 中的某个文件夹 比如先前上传项目的时候有些需要忽略的文件夹并未加入.gitignore文件中,导致上传了一些并不想上传的文件。(比如不小心将下图的.idea、out、nowcoder.iml上传到了github上) github界面上只能删除文件而不能删除文件夹,只能用指令来操作 git rm -r --cached .idea #--cached不会把本地的.idea删除 git commit -m 'delete .idea dir' git push -u origin master
IDEA中
在Idea中使用Git后,类名各种颜色代表的含义
绿色,已经加入控制暂未提交
红色,未加入版本控制
蓝色,加入,已提交,有改动
白色,加入,已提交,无改动
灰色:版本控制已忽略文件。
下载项目:
#提交时转换为LF,检出时不转换
git config --global core.autocrlf input
#拒绝提交包含混合换行符的文件
git config --global core.safecrlf true
#添加改动到暂存区
git add .
#提交本地暂存区
git commit -a -m "提交信息"
#拉取远程最新改动
git pull
-----------解决冲突,重新提交,如果没有冲突 可以直接push
#添加改动到暂存区
git add .
#提交本地暂存区
git commit -a -m "提交信息"
#推送改动到远程
git push
#恢复暂存区改动
git checkout .
查看远程分支
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/master
查看本地分支
$ git branch
* master
创建新分支(本地)
$ git checkout -b temp develop # 等同于 git branch temp 、git checkout temp
创建分支
$ git branch develop
$ git push origin/develop #把develop分支推到远程。
切换分支
$ git checkout develop
Branch develop set up to track remote branch develop from origin.
Switched to a new branch 'develop'
删除本地分支
$ git branch -d feature/transform_20201010 #删除本地分支
#删除远程分支
$ git branch -r -d origin/develop
分支的合并(将develop分支和master分支进行合并)
$ git checkout master
$ git merge develop
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人