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

推荐订阅源

P
Proofpoint News Feed
WordPress大学
WordPress大学
Help Net Security
Help Net Security
Jina AI
Jina AI
Security Latest
Security Latest
Y
Y Combinator Blog
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
D
Docker
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
The Hacker News
The Hacker News
C
Check Point Blog
L
Lohrmann on Cybersecurity
V2EX - 技术
V2EX - 技术
S
Securelist
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
Latest news
Latest news
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Register - Security
The Register - Security
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
O
OpenAI News

博客园 - Mark Jiao

调试Java程序持续占cpu问题 Freemarker notes | Freemarker学习笔记 Spring Struts Hibernate trouble shooting | 一些问题的记载 MySQL 性能调优之查询优化 Tomcat性能调优 | Tomcat Performance Tuning Tomcat配置、管理和问题解决 | Tomcat Configuration, Manangement and Trouble Shooting SWT Browser & XULRunner Windows应用安装制作工具调查报告 CentOS Configuration | CentOS配置 命令行加载IE ActiveX插件 Java那些事儿 互联网技术要考虑的事情 Parameterized Testing | 参数化测试 Introduce products I worked on | 介绍一下我做过的产品 PHPUnit manual note | PHPUnit手册笔记 PHP manual notes | PHP手册笔记 Globalization, Localization, Internationalization and Translation HTTP 超文本传输协议 Design Patter
Git usage | Git 使用
Mark Jiao · 2014-04-22 · via 博客园 - Mark Jiao

Git Help:

[root@vm429.dev unit]# git help

usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]

           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]

           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]

           [-c name=value] [--help]

           <command> [<args>]

The most commonly used git commands are:

   add        Add file contents to the index

   bisect     Find by binary search the change that introduced a bug

   branch     List, create, or delete branches

   checkout   Checkout a branch or paths to the working tree

   clone      Clone a repository into a new directory

   commit     Record changes to the repository

   diff       Show changes between commits, commit and working tree, etc

   fetch      Download objects and refs from another repository

   grep       Print lines matching a pattern

   init       Create an empty git repository or reinitialize an existing one

   log        Show commit logs

   merge      Join two or more development histories together

   mv         Move or rename a file, a directory, or a symlink

   pull       Fetch from and merge with another repository or a local branch

   push       Update remote refs along with associated objects

   rebase     Forward-port local commits to the updated upstream head

   reset      Reset current HEAD to the specified state

   rm         Remove files from the working tree and from the index

   show       Show various types of objects

   status     Show the working tree status

   tag        Create, list, delete or verify a tag object signed with GPG   tag        Create, list, delete or verify a tag object signed with GPG

提交、上传

git commit 提交到本地。

git push提交到遠程服務器。

在本地仓库里添加一些文件,比如README,

$ git add README

$ git commit -m "first commit"

上传到github:

$ git push origin master

3 Steps to merge local changes:

[root@vm514.dev sitecatalyst]# git help commit

[root@vm514.dev sitecatalyst]# git commit -a

[master 7f01ec7] Fix sitecatalyst test errors and failures. Upgrade tests from PHPUnit 3.4.0 to 3.7.27.

13 files changed, 14 insertions(+), 22 deletions(-)

[root@vm514.dev sitecatalyst]# git push

Counting objects: 47, done.

Compressing objects: 100% (21/21), done.

Writing objects: 100% (24/24), 2.03 KiB, done.

Total 24 (delta 13), reused 0 (delta 0)

To git@git.corp.adobe.com:ligyu/sitecatalyst.git

   316256d..7f01ec7  master -> master

[root@vm514.dev sitecatalyst]# git pull

https://git.corp.adobe.com/ligyu/adminModule click “pull request”.

Fetch commits from remote:

[root@vm82.dev sitecatalyst]# git fetch origin master

remote: Counting objects: 9, done.

remote: Compressing objects: 100% (1/1), done.

remote: Total 5 (delta 4), reused 5 (delta 4)

Unpacking objects: 100% (5/5), done.

From git.corp.adobe.com:AdobeAnalyticsWeb/sitecatalyst

* branch            master     -> FETCH_HEAD

[root@vm82.dev sitecatalyst]# git fetch origin master

From git.corp.adobe.com:AdobeAnalyticsWeb/sitecatalyst

* branch            master     -> FETCH_HEAD

[root@vm82.dev sitecatalyst]# git remote -v

origin  git@git.corp.adobe.com:AdobeAnalyticsWeb/sitecatalyst.git (fetch)

origin  git@git.corp.adobe.com:AdobeAnalyticsWeb/sitecatalyst.git (push)

Revert a file change:

If you have not yet added the changes to the index or committed them, then you just want to use the checkout command - this will change the state of the working copy to match the repository:

                git checkout A

If you added it to the index already, use reset:

                git reset A

If you had committed it, then you use the revert command:

                # the -n means, do not commit the revert yet

                git revert -n <sha1>

                # now make sure we are just going to commit the revert to A

                git reset B

                git commit

Rollback/Reset a Git repository to a particular commit

git reset --hard <tag/branch/commit id>

For example:

$ git reset --hard e6b2d58b3d7dd7cbb6375c76aa036a70d03107f2

Sync a fork

https://help.github.com/articles/syncing-a-fork

[httpd@vm514.dev application_platform]$  git remote rm upstream

[httpd@vm514.dev application_platform]$ git remote add upstream git@git.corp.adobe.com:AdobeAnalyticsWeb/application_platform.git

[httpd@vm514.dev application_platform]$ git remote -v

origin  git@git.corp.adobe.com:ligyu/application_platform.git (fetch)

origin  git@git.corp.adobe.com:ligyu/application_platform.git (push)

upstream        git@git.corp.adobe.com:AdobeAnalyticsWeb/application_platform.git (fetch)

upstream        git@git.corp.adobe.com:AdobeAnalyticsWeb/application_platform.git (push)

[httpd@vm514.dev application_platform]$ git branch -a

* master

  remotes/origin/HEAD -> origin/master

  remotes/origin/faster_ad

  remotes/origin/mallet

  remotes/origin/master

  remotes/origin/profile_201309

  remotes/origin/raven

  remotes/origin/realtime

  remotes/origin/v1.1

  remotes/origin/v1.1_profile_201308

  remotes/origin/v1.1_profile_201309

  remotes/upstream/ims-linking

  remotes/upstream/master

  remotes/upstream/middleware-demo

  remotes/upstream/oregon_standup

  remotes/upstream/profile_201310

  remotes/upstream/profile_201311

  remotes/upstream/raven

  remotes/upstream/realtime-fix

  remotes/upstream/spring_2014

  remotes/upstream/targetReport

  remotes/upstream/unifiedfooter

  remotes/upstream/v1.1

  remotes/upstream/v1.1_profile_201310

  remotes/upstream/v1.1_profile_201311

[httpd@vm514.dev application_platform]$ git pull upstream master

[httpd@vm514.dev application_platform]$ git push

Counting objects: 2775, done.

Compressing objects: 100% (609/609), done.

Writing objects: 100% (2463/2463), 573.12 KiB, done.

Total 2463 (delta 1903), reused 2359 (delta 1823)

To git@git.corp.adobe.com:ligyu/application_platform.git

   429c62f..fde3ae0  master -> master

"sync_upstream4folk_as.sh"

cd appservice

REPOS=$(git remote -v)

if [[ $REPOS =~ .*upstream.* ]]

then

        echo "Upstream has been added!"

else

        git remote add upstream git@git.corp.adobe.com:AdobeAnalyticsWeb/appservice.git

fi

git remote -v

git pull upstream master

git push

git pull origin master

"sync_upstream4folk_as2.sh"

cd appservice

REPOS=$(git remote -v)

if [[ $REPOS =~ .*upstream.* ]]

then

        echo "Upstream has been added!"

else

        git remote add upstream git@git.corp.adobe.com:AdobeAnalyticsWeb/appservice.git

fi

git remote -v

git fetch upstream

git branch –va

git checkout master

git merge upstream/master

git push