一、安装Git
- 在Mac的终端上输入git检测是否安装git,如果没有,点击弹出的“安装”按钮。
https://git-scm.com/downloads
- 在终端输入 git --version 查看版本信息
MacBook-Pro ~ % git --version
git version 2.30.1 (Apple Git-130)
- 创建一个全局用户名、全局邮箱作为配置信息
MacBook-Pro ~ % git config --global user.name "dxlxx"
MacBook-Pro ~ % git config --global user.email "1179xxxxxx@qq.com"
- 指令查看Git的配置信息。配置信息可以更改。
MacBook-Pro ~ % git config --list
credential.helper=osxkeychain
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
user.name=dxlxx
user.email=dxl01xx@163.com
- 生成密匙
Git关联远端仓库时候需要提供公钥,本地保存私钥,每次与远端仓库交互时候,远端仓库会用公钥来验证交互者身份。使用以下指令生成密钥,如果有提示,一路点击回车。
MacBook-Pro ~ % ssh-keygen -t rsa -C "ddddk1179222582@dul0101.com"
Generating public/private rsa key pair.
- 显示所有.开头的文件
command+shift+.键 - 密钥路径
id_rsa文件保存的是私钥,保存于本地,id_rsa.pub文件保存的是公钥,需要将里面内容上传到远端仓库。 /Users/dulei/.ssh
复制公钥中的内容 6. 打开你的github账号,在Settings中的左侧边导航中找到SSH and GPG keys,点击左面面板右上方的New SSH key添加密匙。 Title填写自己的备注标题名称(自定义),Key填写刚才id_rsa.pub中的内容。
二、本地搭建仓库
- 创建文件夹
- 目录
/Users/dulei/Downloads/实验室/softwareinstitutionserver
- 在此目录下初始化
MacBook-Pro softwareinstitutionserver % git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /Users/dxxxx/Downloads/实验室/softwareinstitutionserver/.git/
- .git
.git目录 关于版本等所有信息都在这个目录里面
三、克隆远程仓库
- 选择目录
MacBook-Pro / % cd /Users/dulei/Downloads/实验室/softwareinstitutionserver
MacBook-Pro softwareinstitutionserver %
- 克隆
git clone liusx@210.47.17.xxx:FlippedClassroomProject.git
四、本地新项目上传到git
- 将内容写入暂存区
MacBook-Pro:FlippedClassroomProject dulei$ git add .
error: 'extension/' does not have a commit checked out
fatal: adding files failed
MacBook-Pro:FlippedClassroomProject dulei$ git add extension/
error: 'extension/' does not have a commit checked out
fatal: adding files failed
MacBook-Pro:FlippedClassroomProject dulei$ git add .
MacBook-Pro:FlippedClassroomProject dulei$
- 将暂存区内容添加到本地仓库中
MacBook-Pro:FlippedClassroomProject dulei$ git commit -m "2021_12_01"
[master b528039] 2021_12_01
73 files changed, 3645 insertions(+)
create mode 100644 .DS_Store
create mode 100644 Flipped_Chrome/extension/inject.ts
create mode 100755 README.md
create mode 100755 extension.crx
create mode 100755 extension.pem
create mode 100644 extension/.DS_Store
create mode 100755 extension/.vscode/tasks.json
create mode 100755 extension/Readme.md
create mode 100644 extension/_locales/.DS_Store
create mode 100755 extension/_locales/am/messages.json
create mode 100755 extension/_locales/ar/messages.json
create mode 100755 extension/_locales/bg/messages.json
create mode 100755 extension/_locales/bn/messages.json
create mode 100755 extension/_locales/ca/messages.json
create mode 100755 extension/_locales/cs/messages.json
create mode 100755 extension/_locales/da/messages.json
create mode 100755 extension/_locales/de/messages.json
create mode 100755 extension/_locales/el/messages.json
create mode 100755 extension/_locales/en/messages.json
create mode 100755 extension/_locales/en_GB/messages.json
create mode 100755 extension/_locales/en_US/messages.json
create mode 100755 extension/_locales/es/messages.json
create mode 100755 extension/_locales/es_419/messages.json
create mode 100755 extension/_locales/et/messages.json
create mode 100755 extension/_locales/fa/messages.json
create mode 100755 extension/_locales/fil/messages.json
create mode 100755 extension/_locales/fr/messages.json
create mode 100755 extension/_locales/gu/messages.json
create mode 100755 extension/_locales/he/messages.json
create mode 100755 extension/_locales/hi/messages.json
create mode 100755 extension/_locales/hr/messages.json
create mode 100755 extension/_locales/hu/messages.json
create mode 100755 extension/_locales/id/messages.json
create mode 100755 extension/_locales/it/messages.json
create mode 100755 extension/_locales/ja/messages.json
create mode 100755 extension/_locales/kn/messages.json
create mode 100755 extension/_locales/ko/messages.json
create mode 100755 extension/_locales/lt/messages.json
create mode 100755 extension/_locales/lv/messages.json
create mode 100755 extension/_locales/ml/messages.json
create mode 100755 extension/_locales/mr/messages.json
create mode 100755 extension/_locales/ms/messages.json
create mode 100755 extension/_locales/nl/messages.json
create mode 100755 extension/_locales/no/messages.json
create mode 100755 extension/_locales/pl/messages.json
create mode 100755 extension/_locales/pt_BR/messages.json
create mode 100755 extension/_locales/pt_PT/messages.json
create mode 100755 extension/_locales/ro/messages.json
create mode 100755 extension/_locales/ru/messages.json
create mode 100755 extension/_locales/sk/messages.json
create mode 100755 extension/_locales/sl/messages.json
create mode 100755 extension/_locales/sr/messages.json
create mode 100755 extension/_locales/sv/messages.json
create mode 100755 extension/_locales/sw/messages.json
create mode 100755 extension/_locales/ta/messages.json
create mode 100755 extension/_locales/te/messages.json
create mode 100755 extension/_locales/th/messages.json
create mode 100755 extension/_locales/tr/messages.json
create mode 100755 extension/_locales/uk/messages.json
create mode 100755 extension/_locales/vi/messages.json
create mode 100755 extension/_locales/zh_CN/messages.json
create mode 100755 extension/_locales/zh_TW/messages.json
create mode 100755 extension/background.js
create mode 100644 extension/bilibiliController.js
create mode 100755 extension/getBwpVideoTime.js
create mode 100755 extension/getStoragedTime.js
create mode 100755 extension/icon.png
create mode 100755 extension/inject.js
create mode 100755 extension/inject.ts
create mode 100755 extension/inject_style.css
create mode 100755 extension/lib/jquery/jquery-3.4.1.min.js
create mode 100755 extension/manifest.json
create mode 100755 extension/tsconfig.json
- 和自己的仓库建立远程连接
MacBook-Pro:FlippedClassroomProject dulei$ git remote add origin liusx@210.47.17.110:FlippedClassroomProject.git
error: remote origin already exists.
MacBook-Pro FlippedClassroomProject % git remote rm origin
MacBook-Pro FlippedClassroomProject % git remote add origin liusx@210.47.17.xxx:FlippedClassroomProject.git
- 从master分支拉取数据
git pull orgin master
MacBook-Pro FlippedClassroomProject % git pull origin master
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false
hint: git config pull.rebase true
hint: git config pull.ff only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
\S
Kernel \r on an \m
From 210.47.17.xxx:FlippedClassroomProject
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Already up to date.
- 将代码推送到master
git push -u origin master
MacBook-Pro FlippedClassroomProject % git push -u origin master
\S
Kernel \r on an \m
Enumerating objects: 127, done.
Counting objects: 100% (127/127), done.
Delta compression using up to 8 threads
Compressing objects: 100% (71/71), done.
Writing objects: 100% (126/126), 116.50 KiB | 7.77 MiB/s, done.
Total 126 (delta 2), reused 61 (delta 0), pack-reused 0
To 210.47.17.110:FlippedClassroomProject.git
4123b19..b528039 master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
|