惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

Lan小站-嗯,不错! - 综合笔记

Chrome 下载 http 进度 卡住 python-3.9.10-slim-buster Docker 镜像 安装mysqlclient 报错raise OSError("{} not found".format(_mysql_config_path)) OSError: mysql_config not found 八股文题库 - Lan小站-嗯,不错! 【油猴】将github项目在网页版vs code打开,Show Code To Visual Studio 绕过某博客查看文章验证码,关注公众号得验证码 - Lan小站-嗯,不错! AttributeError: module 'asyncio' has no attribute 'to_thread' ffmpeg批量压缩视频 python - Lan小站-嗯,不错! invalid request block size: 6030 (max 4096)...skip 爱普生l310打印机 打印不出蓝色和黄色 但是有墨水 - Lan小站-嗯,不错!
Git 常用指令笔记,pycharm+gitlab,保姆级笔记 - Lan小站-嗯,不错!
Lan · 2023-01-14 · via Lan小站-嗯,不错! - 综合笔记

Lan

本文最后更新于2023年01月15日,已超过1246天没有更新,若内容或图片失效,请留言反馈。

前言

其实,我不用指令来管理代码版本,毕竟Pycharm提供的version control工具这么好用,效率这么高,还用啥指令嘞,但是吧,一切为了准备面试。
www.lanol.cn

然后,昨晚睡不着,刷掘金,发现了一篇文章十分通俗易懂
www.lanol.cn
URL: https://juejin.cn/post/7084966730506141704

因此也想借鉴一篇(码农的事情怎么能说是抄袭呢)
本文将以Pycharm编辑器,Gitlab作为远程仓库介绍相关使用,不使用Github因为他老抽风(刚刚本来想用github演示,结果拉不下来了)。
以我在Github创建的GitDemo为例。
URL: https://gitlab.com/vastsa/gitdemo

常用指令

1. 拉取项目

命令

git clone 仓库地址

操作

其实也可以直接用pycharm的,但是为了体现标题,所以用系统终端拉取。
打开终端,选择好目录。
www.lanol.cn
复制仓库地址。
www.lanol.cn
粘贴回车执行。
www.lanol.cn
如果是首次拉取Github代码,可能需要你登录认证,我之前拉取过,所以就不好演示了。
www.lanol.cn
然后记得cd切换到到项目目录

2. 查看本地分支

命令

git branch

操作

既然说是pycharm,那就打开pycharm的终端,我这里用的是新版ui
www.lanol.cn
执行git branch
目前只有一个main分支,并且颜色为绿色,表示正在当前分支
www.lanol.cn

3. 新建分支

指令

git branch <branch name>

操作

创建一个dev分支,执行git branch dev,然后再执行git brach查看本地分支
新分支会根据现有分支进行创建
www.lanol.cn

4. 切换分支

指令

git checkout <branch name>

操作

我们现在切换到刚刚新建的dev分支,执行指令git checkout dev,并查看本地分支
wwww.lanol.cn

Tip:可以使用git checkout -b <branch name>新建并切换到该分支

5. 查看(文件的)状态报告

指令

git status

操作

执行指令git status,可以查看未提交至暂存区以及发生更改的文件
www.lanol.cn
Tips:

  1. 在提交(commit)代码之前,我们需要将发生变化的文件(staged changes)存入一个位置——暂存区
  2. 暂存区的意义在于,它会追踪变化,只会提交有变化的文件。

6. 添加文件到暂存区

指令

git add <文件名或文件夹>

操作

我新增了三个文件newfilenewhtml.htmltest\newpy.py
执行指令git add .,这个.就表示当前文件夹下的所有文件,也可以直接换成文件名,只添加这一个文件。
wwww.lanol.cn
通过status可以看见,该目录下所有文件以及子目录的文件都添加进暂存区。

7. 提交暂存区文件

指令

git commit -m 'hello www.lanol.cn'

后面这个-m 就是message,就是说明这次提交的,相当于注释。

操作

执行指令git commit -m 'hello www.lanol.cn'
www.lanol.cn

推送分支至远程仓库

指令

git push

操作

我们在本地新建了dev分支,但是远程还没有,这时候我们执行git push的话,会怎么样呢。
www.lanol.cn

fatal: The current branch dev has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin dev

告诉我们需要先用这条指令,推当前分支。
www.lanol.cn

回到gitlab,可以看见文件都已经上来了。
www.lanol.cn