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

推荐订阅源

U
Unit 42
T
Threatpost
C
CERT Recently Published Vulnerability Notes
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
K
Kaspersky official blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
Project Zero
Project Zero
H
Heimdal Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Know Your Adversary
Know Your Adversary
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Schneier on Security
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News | PayPal Newsroom
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
L
LINUX DO - 热门话题
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cloudbric
Cloudbric
V
Vulnerabilities – Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
S
Securelist
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
NISL@THU
NISL@THU
N
News and Events Feed by Topic
S
Security Affairs
The Last Watchdog
The Last Watchdog
T
Tor Project blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
Simon Willison's Weblog
Simon Willison's Weblog
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
C
Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tenable Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security

任峻宏的小站

Debugging Memory Leaks in a Next.js Application Troubleshooting: Resolving Devise Issue in an API-only Application How to Customize a Right-Click Menu in React Using ActionCable and React to Create a Simple Chat App 纪念左耳朵耗子 - 任峻宏的小站 Using SSE to Implement ChatGPT in Rails Refresh Myself - 任峻宏的小站 战痘 - 任峻宏的小站 逆向的能量——生活需要批评者 - 任峻宏的小站 人活着必须要有目标 - 任峻宏的小站 《第一人称单数》读书笔记 - 任峻宏的小站 卸载英雄联盟 - 任峻宏的小站 我的 2021 年总结 - 任峻宏的小站 记我的爷爷 - 任峻宏的小站 Migrate from Webpacker to Vite 从入门到放弃 《人生算法》读书笔记 - 任峻宏的小站 《不拘一格》读书笔记 - 任峻宏的小站 我为什么很少写博客 - 任峻宏的小站 我的2020年总结 - 任峻宏的小站 如何避免冲动消费? - 任峻宏的小站 《不能不去爱的两件事》读书笔记 - 任峻宏的小站 记一次搬家 - 任峻宏的小站 My blog V3.0 has been published! 解决服务器上运行 bundle install 时 killed 的问题 解决生产环境不能发送邮件的问题 - 任峻宏的小站 解决内存泄漏记录 - 任峻宏的小站 勿忘初心 - 任峻宏的小站 关于 RSpec 的一点方法总结 - 任峻宏的小站 使用 AJAX 重载部分页面 - 任峻宏的小站 Nginx 添加 SSL 支持 - 任峻宏的小站 Nginx 中进行重定向配置 - 任峻宏的小站 记我的第二次部署 - 任峻宏的小站 写在“毕业”之际 - 任峻宏的小站 JS 简单实现弹出层效果 - 任峻宏的小站 速递易工作总结及感想 - 任峻宏的小站 在 Aliyun ECS 上用 Nginx + Passenger 部署 Rails 应用时安装 Passenger 的问题 [译] Common Rails Idioms that Kill Database Performance [译] Terminal 功夫——方便开发者的实用技巧 - 任峻宏的小站 实例方法与类方法 - 任峻宏的小站 各种报错解决集合 - 任峻宏的小站
Git 常用操作总结 - 任峻宏的小站
任峻宏 · 2016-12-04 · via 任峻宏的小站

git操作与程序员的日常工作紧密相关,以下列出一些常用的操作

查看远程分支 git branch -a

更新远程分支 git remote update

删除远程分支 git push origin --delete <branchName>git push origin :<branchname>

重命名本地分支 git branch -m <oldname> <newname>

重命名远程分支

在git中重命名远程分支,其实就是先删除远程分支,然后重命名本地分支,再重新提交一个远程分支。

创建并切换分支 git checkout -b newbranch 等价于:

git branch newbranch;
git checkout newbranch

链接远程仓库 git remote add origin <server>

合并commit git rebase -i HEAD~2 链接

恢复到指定的commit(保留代码修改) git reset --soft <resetVersionHash>

恢复到指定的commit(不保留代码修改) git reset --hard <resetVersionHash>

恢复到指定的commit(到 git add 之前的状态,即绿字变红字) git reset <resetVersionHash>git reset --mixed <resetVersionHash> --mixed 是默认参数

git pull时出现冲突,如何放弃本地修改,强制pull远程代码到本地?

git fetch origin  # 获取最新版本
git reset --hard origin/master # 把HEAD指向最新下载的版本

删除暂存区或分支上的文件,但保留本地文件 git rm --cached file_path

修改提交信息(commit message) git commit --amend -m "new-commit-message"

撤销git add(还没有git commit之前) git reset <filename> 撤销所有add的文件: git reset HEAD .

切换分支时保存已修改的代码

假设有两个分支:1和2。我在1上开发了一半,忽然需要切换到2去改bug。 这种情况有两个方法:

1.及时commit代码

在分支1上把已经开发完成的部分代码commit,不push,然后切换到分支2修改代码,做完了commit,所有分支互不影响,这是一个理想的方法。

2.使用git stash

在分支1上:git stash

或者 git stash save “修改的信息"

然后切到分支2修改代码完成,再回到分支1时,使用:git stash pop

或者 git stash list
git stash apply stash@{0} 就可以回到保存的版本了。

解决每次git提交都要输入用户名和密码

1.查看远程仓库: git remote -v

2.此时仓库链接多半是http链接,将其删除: git remote remove origin

3.重新用ssh链接远程仓库: git remote add origin <address> (这个地址应类似git@github.com:xxx.git)

参考文章

http://zengrong.net/post/1746.htm

http://www.cnblogs.com/deepnighttwo/archive/2011/06/18/2084438.html

http://www.tonitech.com/2344.html

http://gitref.org/

http://www.oschina.net/news/68437/seven-git-hacks-you-just-cannot-ignore