简介
git创建本地仓库
-------------------使用 创建一个本地的代码-------------------
1.在官网 https://github.com/ 创建一个新的 Repository仓库
2.在SHELL命令下创建用于存放 git代码的目录
mkdir coding
cd coding
3.在SHELL命令下执行初始化命令
git init
4.执行git remote add 添加在第一步在github中的 Repository仓库
git remote add origin git@github.com:XXXXyourNameXXXX/XXXXyourRepoXXXX.git
5.git add 添加修改文件
git add xxx
6.git commit 提交修改
git commit -m ”说明这次的提交“
7.上传到主分支
git push origin master
git提交代码操作
============提交代码操作=====================
git add XXX
git commit -m "XXXX"
git remote add origin https:git@github.com:ZukGit/IT.git
git push -u origin master
linux下安装git并注册本机秘钥操作
Linux(Ubuntu)下安装使用git
---------------------注册-------------------
1.Shell命令行 Home路径安装git
sudo apt-get install git
2.到git官网注册账号
https://github.com/
3.Shell命令生成ssh秘钥
ssh-keygen -t rsa -C "XXXEmailXXX@qq.com" //对应注册git账号的email 或者能收到邮件的email
4.Home路径下复制生成的 id_rsa.pub 秘钥字符串
cat ~/.ssh/id_rsa.pub //将打印出的字符串复制到剪切板
5.登录到git官网 进入到 Acount Setting 左边选择 SSH Keys , Add SSH Key. title随便选,粘贴入4中的复制字符串
6.测试ssh key是否成功,使用命令“ssh -T git@github.com”,
如果出现You’ve successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上github
从git官网下载自己的git仓库并提交
---------------------使用 创建一个本地的代码-------------------
1.在官网 https://github.com/ 创建一个新的 Repository仓库
2.在SHELL命令下创建用于存放 git代码的目录
mkdir coding
cd coding
3.在SHELL命令下执行初始化命令
git init
4.执行git remote add 添加在第一步在github中的 Repository仓库
git remote add origin git@github.com:XXXXyourNameXXXX/XXXXyourRepoXXXX.git
5.git add 添加修改文件
git add xxx
6.git commit 提交修改
git commit -m ”说明这次的提交“
7.上传到主分支
git push origin master
从git克隆代码到本地
---------------------从git克隆代码到本地-------------------
1.在官网 https://github.com/ 找到一个要克隆到本地的 Repository仓库 的路径
git@github.com:ZukGit/20160905.git
2.在SHELL命令下切换到对应本地代码的文件夹
mkdir XXXX
cd XXXX
3.执行命令
git clone git@github.com:ZukGit/Source_Code.git
拉完进入本地仓库
cd 20160905
4.git add 添加修改文件
git add xxx
5.git commit 提交修改
git commit -m ”说明这次的提交“
6.上传
git push
Windows下安装使用git
Windows下安装使用git
---------------------------------------
1.下载安装git for windows
2.创建 文件夹 git_dir 右键 点击 git bash 进入 bash shell 界面
3.创建 ssh共秘钥
cd ~/.ssh ## 如果没有这个文件夹则创建这个文件夹 mkdir ~/.ssh
cd ~ ##保证当前路径在”~”下
ssh-keygen -t rsa -C "382581427@qq.com" ## 生成 秘钥文件
cd ~/.ssh/ ## 进入.ssh 文件夹
cat ./id_rsa.pub ## 查看公钥文件 并复制到 github自己账号下的 SSH Key中
git config --global user.name "Zukgit-windos10-Mac" ## 配置用户名
git config --global user.email "382581427@qq.com" ## 配置邮箱
ssh -T git@github.com ## 检测当前是否正确配置 能与github进行连接
git clone git@github.com:ZukGit/Source_Code.git ## 拉取对应的github仓库 repositories
## 在github主页 Settings > Developer settings > personal access tokens > General new Token(按钮)
1.设置 Token的名字 建议: 名字_系统_设备
2.设置Token 有效期 Expiration : 建议为 No Expiration 无期限
3.设置 Select scopes , 建议全选
4.点击 General Token 按钮 生成 Token
5. 复制 General Token 类似如下字符串(改字符串只出现一次 一定要复制保存 刷新无 )
ghp_vRaoDiY2kDXi4oLiAbA3xPEFAwIiff40qluy
6. 依据如下范式 输入当前有需求的 git仓库地址
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
<your_token>:换成你自己得到的token <USERNAME>:是你自己github的用户名 <REPO>:是你的仓库名称
例:
git remote set-url origin https://ghp_vRaoDiY2kDXi4oLiAbA3xPEFAwIiff40qluy@github.com/ZukGit/win_rbin.git
——————————————————————————————————————————————————————
在2021年 8 月 13 日之后,如果你还用账户密码来操作 Github 上的仓库,就会收到以下警告:
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
fatal: unable to access 'https://github.com/<user>/<repo>/': The requested URL returned error: 403
必须使用个人访问令牌(personal access token),就是把你的密码替换成token!
这样再使用终端 git push 就成功啦!
设置gitaction
DirFileSummary_Action
1.修改Git 仓库Setting中的 Permission 运行 Action 提交上传
Git 》 Setting 》 Workflow permissions 》 Read and write permissions
无权限 将打印如下信息 导致 Action 无法 更新文件
2024-12-21T03:03:47.7270485Z remote: Write access to repository not granted.
2024-12-21T03:03:47.7271824Z fatal: unable to access 'https://github.com/xxxx/xxxx_action/': The requested URL returned error: 403
2.定义 main.yml 文件 【新的 mp4_Action 需要替换新的 git名称】 .github/workflows/main.yml
# This is a basic workflow to help you get started with Actions
name: DirFileSummary_Action
# Controls when the workflow will run
on:
schedule:
- cron: '*/2 * * * *'
# Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [ main ]
# pull_request:
# branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
env:
git_name: mp4_lin_action1_2412
# Runs a single command using the runners shell
- name: Run FileSummary For mp4_lin_action1_2412
run: |
echo ___________tree_begin ___________
tree
echo ___________tree_end___________
echo ___________dir_begin___________
# Directory: D:\a\mp4_lin_action1_2412\mp4_lin_action1_2412
dir
echo ___________dir_end___________
echo Hello, mp4_lin_action1_2412!
echo ___________java_begin___________
java -version
java
echo ___________java_end___________
echo ___________python_begin___________
python --version
echo ___________python_end___________
echo $git_name
dir
cmd
echo zbatrule_I9_Rule30.bat
echo ___________PATH_begin___________
echo ___________ PATH end___________
echo ___________env_begin___________
env
echo ___________env_end___________
echo USERPROFILE__Begin $USERPROFILE
echo ___________cmdA_begin___________
dir
xcopy /y /c /e /h /r /s zbin\*.* C:\Users\runneradmin\Desktop\zbin\
cmd /K C:\Users\runneradmin\Desktop\zbin\win_zbin\zrule_apply_G2.bat
echo ___________cmdA_end___________
cmd /K C:\Users\runneradmin\Desktop\zbin\win_zbin\zrule_apply_G2.bat _71 D:\a\mp4_lin_action1_2412\mp4_lin_action1_2412\zapp\ outdir_D:\a\mp4_lin_action1_2412\mp4_lin_action1_2412\ outname_README.md
git config --global user.email "ZukGit"
git config --global user.name "382581427@qq.com"
cmd /K zbatrule_I9_Rule30.bat _33_
# git status
# git add .
# git commit -m "update by mp4_lin_action1_2412 to calculate file_summary json_status"
# git push
# git log
cd D:\a\mp4_lin_action1_2412\mp4_lin_action1_2412\
dir
# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
设置git快捷环境变量
在windows的系统环境变量中 设置 变量 gitpath 值为 C:\Users\aaa\Desktop\git_code\Source_Code
在 bash/shell 中 能直接通过 cd $gitpath 切换到git仓库的主目录
alias gitpath="C:\Users\aaa\Desktop\git_code\Source_Code"
cd gitpath
加速git访问速度
git访问速度 下载速度慢
http://blog.csdn.net/sunsteam/article/details/63253933
windows下配置git
https://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html