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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - JackieHan

ubuntu i3 xterm中文输入显示问题解决 ubuntu vim markdown 实时预览 ubuntu docker方式部署docker registry v2 docker 安装 gogs(go git server) 及问题解决 ubuntu14.04 server 安装docker Ubuntu Tomcat Ubuntu ssh 代理 全网访问速度优化 vim使用指北 ---- Multiple Windows in Vim vim使用指北 ---- Advanced Editing vim使用指北 ---- Global Replacement vi/vim使用指北 ---- Introducting the ex Editor ubuntu 点点滴滴 vi/vim使用指北 ---- Learning the vi and Vim Editors 读书 笔记 vi/vim使用指北 ---- Beyond the Basic vi/vim使用指北 ---- Moving Around in a Hurry vi/vim使用指北 ---- Sample Editing linux权威指南 简记 idea 使用
git 操作
JackieHan · 2014-10-09 · via 博客园 - JackieHan

2014-10-09 17:18  JackieHan  阅读(258)  评论()    收藏  举报

基本操作

  • 初始化

git init   当前目录就可以使用git 管理,创建一个新的目录.git

  • 暂存区操作

git add file  添加文件到git管理  (Untracked files)

                  把已在git管理的已修改的文件提交暂存区 (Changes not staged for commit)

                  合并时把有冲突的文件标记为已解决的状态

git diff    查看当前工作区和暂存区的差异

git diff --staged   查看暂存区和上次提交的差异

git commit -m 'commit discription'  提交已暂存的文件

git commit -am 'commit discription' 跳过暂存区提交文件

git commit  --amend  使用当前暂存区提交,修改最后一次提交

git reset HEAD <file>  取消已暂存的文件

git checkout -- <file>  取消对文件的修改

git rm file  从暂存区删除该文件

git mv file_from file_to  从命名文件

git status   查看当前文件状态

  • 远程仓库

git clone url  localDirctory   克隆远程项目到本地目录

git remote  查看远程仓库

git fetch [remote-name]   从远程仓库抓取数据

git push [remote-name]  [branche-name]   推送数据到远程仓库

git remote show [remote-name]  查看远程仓库信息

git remote add origin giturl    推送本地存在的git仓库到服务器

  • 日志

git log   查看所有日志

             -p 显示每次提交的内容差异

             -n(数字) 现实最近n次的日志

标签管理

git tag   列出所有标签

git tag -l 'v1.*'  列出所有已v1.开头的标签

git tag -a tagname -m 'tag discription'  添加一个含附注的标签

git tag -s tagname -m 'tag discription'  用GPG签署标签

git tag tagname 添加一个轻量级的标签

git tag -d tagname 删除一个标签

git push origin tagname  推送tag到服务器上

git push origin --tags  推送所有tag到服务器上

git tag -d tagname   ==> git push origin :refs/tags/tagname   删除服务器上的分支(先删除本地分支,然后推送变化到服务器)

git clone --branche tagename url   从服务器克隆给定tag的代码

管理分支

  • 查看分支

git branch  当前分支列表,有“*”号的那个分支,为当前工作分支

git branch -v  分支列表,加上最后一个提交信息

git branch -r  查看所有远程分支

git branch -a  查看所有分支

git branch --merge  可以查看有哪些分支已经并入到当前分支了

git branch --no-merge  可以查看哪些分支还没并入 当前分支

  • 添加本地分支:

git branch branchname   创建一个本地 分支

git checkout -b branchname     创建一个本地分支并设置该分支为当前工作分支

  • 切换本地分支:

git checkout branchname   把当前工作分支切换到指定分支

  • 合并本地分支:

假如你建立了一个hotfix分支,工作完成后需要把合并到master分支

git checkout master    切换到master分支

git merge hotfix    把hotfix分支的修改内容合并到master分支

  • 解决分支合并中的冲突:

git 合并操作提示CONFLICT,表示出现合并冲突,使用git status 查看,both modified   fileName  表示该文件有冲突,打开该文件,可以看到:

<<<<<<<<HEAD

some content

=========

some other content

>>>>>>>>>>>> branch name

手工合并后保存,git status 查看后该文件状态为modified,之后提交合并结果完成冲突处理

  • 删除分支

git branch -d branchname     删除本地分支

  • 推送本地分支

git push origin localbranch   推送本地分支到服务上

  • 比较本地分支和远程分支

git diff local_branch  origin/remote_branch  比较本地分支和服务器分支差异    可判断本地分支是否需要提交到服务器

git 高级应用

  • 10个很有用的高级git命令

http://www.oschina.net/translate/10-useful-advanced-git-commands

  • a few git tip you didn't know about

http://mislav.uniqpath.com/2010/07/git-tips/

  • git update commit history author info

http://blog.chinaunix.net/uid-25871104-id-3575141.html 

get web

  • 404 - projects not found

配置的路径,无权限,直接设置777就好