git.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sat, 10 Feb 2018 01:36:16 +0200
changeset 2229 1a0b6597e594
parent 2214 f7b3d90697ab
child 2232 ac7f6d8bea28
permissions -rw-r--r--
Mark block quot in HTMLe.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     1
.. -*- coding: utf-8; -*-
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
======
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
 Git.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
======
1032
4decc3e00bb6 Fix coding and contents.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1002
diff changeset
     6
.. contents::
1905
fba288d59662 Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1815
diff changeset
     7
   :local:
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
2101
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
     9
Setting up git
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    10
==============
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    11
2101
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    12
Debian::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
2081
0d9703b4a428 Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1932
diff changeset
    14
  $ sudo apt-get install git
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
2101
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    16
Cygwin::
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    17
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    18
  $ setup.exe -p git
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    19
  $ apt-cyg install git
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    20
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    21
After install set up some options::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    22
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    23
  $ git config --global user.name "Oleksandr Gavenko"
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    24
  $ git config --global user.mail "gavenkoa@gmail.com"
2101
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    25
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    26
After that you should have::
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    27
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    28
  $ cat ~/.gitconfig
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    29
  [user]
2101
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    30
  name = Oleksandr Gavenko
325b195030bd Simplify text.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2085
diff changeset
    31
  mail = gavenkoa@gmail.com
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    32
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    33
git over proxy.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    34
===============
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    35
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    36
Only http:// protocol support proxy (not git://)::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    37
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    38
  $ export http_proxy="http://username:password@proxy:port/"
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    39
  $ git clone http://github.com/$user/$proj.git $proj
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    40
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    41
You can store proxy settings under repository local config file::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    42
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    43
  $ git config http.proxy http://$user:$passwd@$ip:$port
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    44
2081
0d9703b4a428 Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1932
diff changeset
    45
Start project with git
0d9703b4a428 Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1932
diff changeset
    46
======================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    47
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    48
Setup proj space on fs::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    49
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    50
  $ mkdir proj
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    51
  $ cd proj
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    52
  $ git init
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    53
  Initialized empty Git repository in /home/user/tmp/proj/.git/
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    54
  $ ls -a
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    55
  . .. .git
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    56
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    57
Add file, make changes, commit all::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    58
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    59
  $ emacs Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    60
  ... C-x C-c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    61
  $ emacs app.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    62
  ... C-x C-c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    63
  $ git add Makefile app.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    64
  $ git status
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    65
  # On branch master
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    66
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    67
  # Initial commit
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    68
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    69
  # Changes to be committed:
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    70
  #   (use "git rm --cached <file>..." to unstage)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    71
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    72
  #       new file: Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    73
  #       new file: app.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    74
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    75
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    76
or just::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    77
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    78
  $ git add .
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    79
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    80
Commit newlly added file::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    81
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    82
  $ git commit
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    83
  ... Write message log ...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    84
  Created initial commit 2169263: My first commit massage.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    85
   1 files changed, 4 insertions(+), 0 deletions(-)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    86
   create mode 100644 app.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    87
2209
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    88
Show difference
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    89
===============
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    90
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    91
Show difference between index/stage and working tree::
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    92
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    93
  $ git diff
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    94
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    95
Show difference between ``HEAD`` and index (what is going to be commited)::
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    96
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    97
  $ git diff --cached
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    98
  $ git diff --staged
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
    99
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   100
.. note:: ``--cached`` and ``--staged`` are synonyms.
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   101
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   102
Show difference beetween ``HEAD`` and working tree (what is commited after ``git commit -a``)::
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   103
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   104
  $ git diff HEAD
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   105
  $ git diff HEAD -- $path
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   106
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   107
Show difference in changeset::
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   108
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   109
  $ git show $hash
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   110
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   111
Show difference between revisions::
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   112
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   113
  $ git diff $rev1..$rev2
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   114
  $ git diff ORIG_HEAD..HEAD
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   115
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   116
https://stackoverflow.com/questions/3293607/difference-between-git-head-and-the-current-project-state
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   117
  Difference between git HEAD and the current project state?
6faf149a4f4c Show difference.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2195
diff changeset
   118
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   119
Undo tracking added file.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   120
=========================
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   121
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   122
You do::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   123
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   124
  $ git add badfile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   125
  $ git status
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   126
  # On branch master
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   127
  # Changes to be committed:
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   128
  #   (use "git reset HEAD <file>..." to unstage)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   129
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   130
  #       new file:   badfile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   131
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   132
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   133
To stop tracking badfile do::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   134
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   135
  $ git rm --cached badfile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   136
  $ git status
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   137
  # On branch master
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   138
  # Untracked files:
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   139
  #   (use "git add <file>..." to include in what will be committed)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   140
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   141
  #       file
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   142
  nothing added to commit but untracked files present (use "git add" to track)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   143
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   144
or::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   145
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   146
  $ git reset badfile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   147
2082
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   148
Committing changes
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   149
==================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   150
2082
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   151
Individual file::
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   152
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   153
  $ $EDITOR Makefile
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   154
  $ git add Makefile
2152
a48ba30d5b20 Fixed example for done changes review.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2126
diff changeset
   155
  $ git diff --cached
2082
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   156
  $ git commit -m "..."
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   157
2082
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   158
Commit all changed and previously manages files::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   159
2082
7f6ce6b18a0c Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2081
diff changeset
   160
  $ git commit -a -m "...."
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   161
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   162
Managing branches
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   163
=================
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   164
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   165
Print current branch::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   166
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   167
  $ git branch
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   168
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   169
List all known branches::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   170
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   171
  $ git branch -a
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   172
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   173
List all known remote branches::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   174
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   175
  $ git branch -r
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   176
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   177
List all remote branches (from all remotes)::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   178
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   179
  $ git ls-remote
2190
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   180
  $ git ls-remote origin
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   181
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   182
List registered remotes::
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   183
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   184
  $ git remote show
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   185
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   186
List remote branches from ``$REMOTE`` remote::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   187
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   188
  $ git ls-remote --heads $REMOTE
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   189
  $ git remote show $REMOTE
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   190
2190
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   191
Special case of above is ``origin`` remote, which is default remote::
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   192
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   193
  $ git remote show origin
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   194
  $ git ls-remote --heads origin
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   195
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   196
.. note::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   197
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   198
   Look to ``[remote "..."]`` in ``~/.git/config`` to find out names of possible
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   199
   remotes. Alternatively get list from::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   200
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   201
     $ git remote show
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   202
2190
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   203
Getting branches pointers from default (``origin``) remote (without merging
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   204
tracking branch)::
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   205
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   206
  $ git fetch
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   207
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   208
Getting branches pointers from ``$REMOTE`` remote::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   209
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   210
  $ git fetch $REMOTE
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   211
2190
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   212
To get updated with default remote changes::
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   213
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   214
  $ git pull
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   215
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   216
or specify concrete remote::
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   217
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   218
  $ git pull $REMOTE
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   219
  $ git pull origin
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   220
2214
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   221
Delete local branch::
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   222
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   223
  $ git branch -d $NAME
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   224
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   225
Delete remote branch remotely::
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   226
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   227
  $ git push --delete $REMOTE $BRANCH_NAME
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   228
  $ git push -d $REMOTE $BRANCH_NAME
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   229
  $ git push -d origin $BRANCH_NAME
f7b3d90697ab Delete remote branch remotely.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2211
diff changeset
   230
2190
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   231
To locally remove pointers to deleted remotely branches::
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   232
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   233
  $ git remote update --prune
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   234
  $ git remote update --prune origin
f589976b8876 Reindent RST code.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2179
diff changeset
   235
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   236
.. note::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   237
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   238
   Only curtain branches fetched by default::
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   239
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   240
     [remote "origin"]
2123
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   241
     url = ...
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   242
     fetch = +refs/heads/*:refs/remotes/origin/*
2084
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   243
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   244
   Edit ``fetch`` value to change defaults.
376824d203c2 Managing branches.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2082
diff changeset
   245
2171
2ded7f1cf6c0 Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2153
diff changeset
   246
Move branch pointer to arbitrary hash::
2ded7f1cf6c0 Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2153
diff changeset
   247
2ded7f1cf6c0 Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2153
diff changeset
   248
  $ git branch -f $NAME $HASH
2ded7f1cf6c0 Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2153
diff changeset
   249
2085
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   250
git analog of 'hg incoming'
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   251
===========================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   252
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   253
git does not directly support such feature. You can emulate it by::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   254
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   255
  $ git fetch
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   256
  $ git log master..origin/master   # or just '..origin/master'
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   257
2085
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   258
By previous commands you grab changes from remote server! You can apply them by
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   259
``pull`` or ``merge`` or ``rebase`` command::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   260
2085
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   261
  $ git pull
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   262
  $ git merge
2085
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   263
  TODO
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   264
2085
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   265
To detect if remote repository have new changes::
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   266
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   267
  $ git ls-remote
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   268
  $ git ls-remote $upstream
652aca73fc06 Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2084
diff changeset
   269
2126
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   270
View git commits
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   271
================
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   272
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   273
Review specific commit with::
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   274
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   275
  $ git show $REV
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   276
  $ git diff $REV^ $REV
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   277
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   278
Review difference between commits::
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   279
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   280
  $ git $REV1 $REV2
2153
e88e36e73ebc Review difference between commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2152
diff changeset
   281
  $ git $REV1..$REV2
e88e36e73ebc Review difference between commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2152
diff changeset
   282
  $ git $REV1..$REV2 -- $DIR_OR_FILE
2126
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   283
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   284
Review history with diffs::
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   285
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   286
  $ git log -p
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   287
  $ git log -p $FROM_REV
09e2e50d02aa View git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2124
diff changeset
   288
2122
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   289
View unpublished git commits / analog of git 'hg outgoing'
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   290
==========================================================
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   291
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   292
``git`` does not directly support such feature. Recently ``hg`` start tracking
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   293
changes that pushed to any other repositories (called as ``public`` versus
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   294
``draft`` which is not yet published anywhere). You can emulate it by::
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   295
2122
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   296
  $ git fetch origin
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   297
  $ git log origin/master..master
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   298
  $ git log origin/master..
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   299
  $ git log origin/master..HEAD
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   300
  $ git log @{u}..
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   301
2122
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   302
  $ git diff origin/master..
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   303
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   304
Verbose syntax::
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   305
24fbab64cf91 View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2116
diff changeset
   306
  $ git log --branches --not --remotes
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   307
2123
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   308
http://stackoverflow.com/questions/2016901/viewing-unpushed-git-commits
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   309
  Viewing unpushed Git commits.
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   310
http://stackoverflow.com/questions/3636914/how-can-i-see-what-i-am-about-to-push-with-git
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   311
  How can I see what I am about to push with git?
f98c2b2e6c07 View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2122
diff changeset
   312
2102
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   313
git analog of 'hg glog'
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   314
=======================
1650
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   315
::
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   316
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   317
  $ git log --all --graph
2102
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   318
  $ git log --all --graph --oneline
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   319
  $ git log --all --graph --oneline --decorate
1650
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   320
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   321
Add alias::
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   322
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   323
  [alias]
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   324
  glog = log --all --graph
a48c3c61d0f9 git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1641
diff changeset
   325
2116
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   326
Git analog of 'hg rollback'
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   327
===========================
1651
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   328
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   329
To edit commit message of last commit::
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   330
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   331
  $ git commit --amend -m "$MSG"
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   332
2116
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   333
To integrate changes into last commit (``-a`` to avoid antecedent ``git add ...``,
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   334
``--no-edit`` if you don't like to change commit message, otherwise external
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   335
editor is opened)::
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   336
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   337
  $ git commit -a --amend --no-edit
f92d8941f4a8 Git amend.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2115
diff changeset
   338
1651
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   339
To edit messages of old commits starting from ``$REV``::
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   340
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   341
  $ git rebase -i $REV
c77807176b36 Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1650
diff changeset
   342
2124
3afe57643e44 undo latest commit
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2123
diff changeset
   343
To undo latest commit::
3afe57643e44 undo latest commit
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2123
diff changeset
   344
3afe57643e44 undo latest commit
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2123
diff changeset
   345
  $ git reset HEAD~1
3afe57643e44 undo latest commit
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2123
diff changeset
   346
2102
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   347
Git analog of 'hg root'
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   348
=======================
1771
b2d4be61da16 Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
   349
::
b2d4be61da16 Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
   350
b2d4be61da16 Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
   351
  $ git rev-parse --show-toplevel
b2d4be61da16 Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1714
diff changeset
   352
2102
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   353
Making local branch tracking remote
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   354
===================================
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   355
::
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   356
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   357
  $ git branch -u upstream/foo
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   358
  $ git branch -u upstream/foo foo
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   359
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   360
  $ git branch --set-upstream-to=upstream/foo
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   361
  $ git branch --set-upstream-to=upstream/foo foo
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   362
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   363
Showing what and how local branches are tracked::
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   364
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   365
  $ git branch -vv
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   366
  $ cat .git/gitconfig
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   367
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   368
Showing what remote branches tracked::
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   369
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   370
  $ git remote show $remote
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   371
2115
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   372
Undo mistaken rebase
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   373
====================
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   374
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   375
If there are no any ``reset``, ``rebase`` or ``merge`` afterwards the easiest
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   376
way to recode to pre-rebase state is one of::
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   377
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   378
  $ git rebase --abort
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   379
  $ git reset --hard ORIG_HEAD
0263a79eeb3b Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2102
diff changeset
   380
2172
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   381
Otherwise look to::
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   382
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   383
  $ git reflog
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   384
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   385
and reset to necessary head::
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   386
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   387
  $ git reset --hard "HEAD@{...}"
850d2d84e4c8 Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2171
diff changeset
   388
2173
69aed373ceb9 Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2172
diff changeset
   389
https://stackoverflow.com/questions/134882/undoing-a-git-rebase
69aed373ceb9 Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2172
diff changeset
   390
  Undoing git rebase.
69aed373ceb9 Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2172
diff changeset
   391
2179
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   392
Undo reset --hard
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   393
=================
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   394
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   395
``git reset --hard`` is destructive command without backup data.
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   396
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   397
You may find your previously added data in Git garbage::
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   398
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   399
  $ git fsck --lost-found
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   400
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   401
look to files inside ``.git/lost-found`` directory.
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   402
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   403
Reviewing ``git reflog`` also may help.
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   404
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   405
* https://stackoverflow.com/questions/5788037/recover-from-git-reset-hard
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   406
* https://stackoverflow.com/questions/14251194/how-to-recover-after-i-execute-git-reset-hard-head
178897af315a Undo reset --hard.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2176
diff changeset
   407
2175
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   408
Git bisect
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   409
==========
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   410
2176
40c43e30c7fa Git bisect term.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2175
diff changeset
   411
``bad`` changes should be later in graph history then ``good`` ones. To use
40c43e30c7fa Git bisect term.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2175
diff changeset
   412
alternative names::
40c43e30c7fa Git bisect term.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2175
diff changeset
   413
40c43e30c7fa Git bisect term.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2175
diff changeset
   414
  $ git start --term-old=... --term-new=...
2175
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   415
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   416
Start bisecting with::
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   417
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   418
  $ git bisect start
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   419
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   420
Mark good and bad revisions::
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   421
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   422
  $ git co vBAD
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   423
  $ make test
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   424
  $ git bisect bad
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   425
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   426
  $ git co vGOOD
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   427
  $ make test
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   428
  $ git bisect good
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   429
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   430
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   431
If build/test failed to complete use::
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   432
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   433
  $ git bisect skip
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   434
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   435
To restore mistakenly marked revisions::
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   436
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   437
  $ git bisect log >$LOG
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   438
  $ git bisect reset
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   439
  $ $EDITOR $LOG
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   440
  $ git bisect replay $LOG
3977f49ae241 Git bisect.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2173
diff changeset
   441
2211
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   442
Import patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   443
============
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   444
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   445
Check patch summary::
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   446
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   447
  git apply --stat my.patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   448
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   449
Detect possible errors during patch application::
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   450
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   451
  git apply --check my.patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   452
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   453
Apply patch to working tree without commit::
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   454
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   455
  git apply my.patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   456
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   457
Commit patch::
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   458
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   459
  git am my.patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   460
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   461
Commit patch by signing you as reviewer::
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   462
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   463
  git am --signoff my.patch
473f6c2b0fdf Import patch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2209
diff changeset
   464
2102
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   465
Debug git network operation
ce5d8887b874 Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2101
diff changeset
   466
===========================
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   467
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   468
Git uses libcurl for network operation::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   469
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   470
  $ export GIT_CURL_VERBOSE=1
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   471
  $ git ...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   472
1076
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   473
Push new repo to remote.
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   474
========================
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   475
::
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   476
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   477
  $ mkdir $REPO
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   478
  $ cd $REPO
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   479
  $ git init
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   480
  $ git add .
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   481
  $ git commit -m "Initial commit"
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   482
  $ git remote add origin https://$USER:$PASS@$HOST/$REPO
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   483
  $ git push -u origin master
9b2eb3c96d84 Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1032
diff changeset
   484
1641
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   485
Show heads in branch.
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   486
=====================
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   487
::
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   488
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   489
  $ git show-ref --heads -s
04e215a475e0 Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1334
diff changeset
   490
1932
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   491
Search string in file
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   492
=====================
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   493
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   494
To search string in all or specific files or working copy::
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   495
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   496
  $ git grep $PATT
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   497
  $ git grep -i $PATT -- '*.[ch]'
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   498
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   499
To search in all history::
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   500
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   501
  $ git log -S$PATT
2195
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   502
  $ git log --pickaxe-regex=$PATT
1932
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   503
  $ git log -G$PATT
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   504
  $ git grep -i PATT $(git rev-list --all) -- '*.[ch]'
6b987b040e18 Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1912
diff changeset
   505
2195
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   506
.. note::
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   507
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   508
   ``-S`` search occurences in diff chunks, while ``-G`` detects changes in match count.
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   509
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   510
https://git-scm.com/book/en/v2/Git-Tools-Searching
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   511
  Git Tools - Searching.
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   512
https://stackoverflow.com/questions/1337320/how-to-grep-git-commit-diffs-or-contents-for-a-certain-word
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   513
  How to grep Git commit diffs or contents for a certain word?
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   514
https://stackoverflow.com/questions/4468361/search-all-of-git-history-for-a-string
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   515
  Search all of Git history for a string?
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   516
https://stackoverflow.com/questions/2928584/how-to-grep-search-committed-code-in-the-git-history
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   517
  How to grep (search) committed code in the git history?
3556ec0e48be Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 2190
diff changeset
   518
1089
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   519
Find most recent tag for revision.
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   520
==================================
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   521
::
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   522
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   523
  $ git describe $REV
2c23dfe7517e Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1076
diff changeset
   524
1815
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   525
Many projects set tags on branches rather then mainline (for example JS/CSS
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   526
projects perform build and commit binary/minified files, which unnecessary for
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   527
mainline history). In this case review simplifiied history by::
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   528
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   529
  $ git log --graph --all --decorate --oneline --simplify-by-decoration
49fb4309d4d0 Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1771
diff changeset
   530
1714
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   531
List tags with dates.
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   532
=====================
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   533
::
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   534
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   535
  $ git log --tags --simplify-by-decoration --pretty="format:%ci %d"
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   536
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   537
Update to date.
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   538
===============
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   539
::
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   540
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   541
  $ git checkout 'master@{1979-02-26}'
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   542
  $ git checkout 'master@{1979-02-26 18:30:00}'
eed8cfffa44e List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 1651
diff changeset
   543
1002
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   544
Using git to work with SVN offline.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   545
===================================
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   546
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   547
Prepare SVN and git utilities::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   548
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   549
  $ sudo apt-get svn git-core git-svn
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   550
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   551
Making SVN repo::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   552
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   553
    $ cd $HOME/tmp
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   554
    $ svnadmin create svn-repo
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   555
    $ svn co file://$HOME/tmp/svn-repo svn-devel
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   556
    $ cd svn-devel
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   557
    $ mkdir tags trunk branches
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   558
    $ svn add *
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   559
  A         branches
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   560
  A         tags
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   561
  A         trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   562
    $ cd trunk/
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   563
    $ printf "all:\n  echo XXX\n" >Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   564
    $ printf "int main() {return 0;}" >main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   565
    $ svn add *
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   566
    $ cd ..
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   567
    $ svn st
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   568
  A      trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   569
  A      trunk/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   570
  A      trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   571
  A      branches
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   572
  A      tags
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   573
    $ svn ci -m init
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   574
  Adding         branches
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   575
  Adding         tags
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   576
  Adding         trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   577
  Adding         trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   578
  Adding         trunk/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   579
  Transmitting file data ..
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   580
    $ svn cp -m v0.0 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/tags/v0.0
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   581
    $ svn cp -m v0.1 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/branches/v0.1
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   582
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   583
Moving SVN changset to git repo::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   584
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   585
    $ cd $HOME/tmp
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   586
    $ git svn init file://$HOME/tmp/svn git-repo
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   587
    $ ls -a
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   588
  .  ..  .git
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   589
    $ git svn fetch
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   590
      A   trunk/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   591
      A   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   592
  W: +empty_dir: branches
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   593
  W: +empty_dir: tags
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   594
  r1 = 52ccd9882979dd53ec198dbac108783ec660410f (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   595
      A   tags/v0.0/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   596
      A   tags/v0.0/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   597
  r2 = 8ec8a772bb6f37ace56b3649066dc84e481ed427 (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   598
      M   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   599
  r3 = 2c169ff409ed504dd6a092b1e302beb3fd94871e (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   600
      A   branches/v0.1/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   601
      A   branches/v0.1/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   602
  r4 = e68d76f4ba6beea4b9059c1884c1f38ce10831a7 (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   603
      M   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   604
  r5 = cdde63974454b13ac53f2eeb201aa76c49fd875c (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   605
  Checked out HEAD:
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   606
    file:///home/sasha/tmp/svn r5
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   607
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   608
or (in old git version)::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   609
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   610
  $ git svn clone file://$HOME/tmp/svn git-repo
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   611
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   612
Making changes in svn::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   613
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   614
    $ cd $HOME/tmp/svn-devel/trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   615
    $ echo ".PHONY: clean" >>Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   616
    $ svn ci -m "Added clean to phony."
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   617
  Sending        trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   618
  Transmitting file data .
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   619
  Committed revision 6.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   620
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   621
Making committed in git::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   622
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   623
    $ cd $HOME/tmp/git-repo/trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   624
    $ echo ".PHONY: all" >>Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   625
    $ echo "int foo(int x) {return x+x;}" >>main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   626
    $ git status
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   627
  # On branch master
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   628
  # Changed but not updated:
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   629
  #   (use "git add <file>..." to update what will be committed)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   630
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   631
  #       modified:   Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   632
  #       modified:   main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   633
  #
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   634
  no changes added to commit (use "git add" and/or "git commit -a")
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   635
    $ git commit -a -m "Bug fixed."
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   636
  Created commit 222d399: Bug fixed.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   637
   2 files changed, 2 insertions(+), 0 deletions(-)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   638
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   639
Getting changes from SVN to git::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   640
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   641
    $ git svn rebase
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   642
      M   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   643
  r6 = 8165e9bfb38e9df09a7313d19606ec227629b670 (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   644
  First, rewinding head to replay your work on top of it...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   645
  Applying Bug fixed.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   646
  error: patch failed: trunk/Makefile:6
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   647
  error: trunk/Makefile: patch does not apply
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   648
  Using index info to reconstruct a base tree...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   649
  Falling back to patching base and 3-way merge...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   650
  Auto-merged trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   651
  CONFLICT (content): Merge conflict in trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   652
  Failed to merge in the changes.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   653
  Patch failed at 0001.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   654
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   655
  When you have resolved this problem run "git rebase --continue".
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   656
  If you would prefer to skip this patch, instead run "git rebase --skip".
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   657
  To restore the original branch and stop rebasing run "git rebase --abort".
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   658
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   659
  rebase refs/remotes/git-svn: command returned error: 1
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   660
    $ git add Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   661
    $ git rebase --continue
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   662
  Applying Bug fixed.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   663
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   664
and return all from git to SVN::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   665
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   666
    $ git svn dcommit
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   667
  Committing to file:///home/sasha/tmp/svn ...
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   668
      M   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   669
      M   trunk/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   670
  Committed r7
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   671
      M   trunk/main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   672
      M   trunk/Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   673
  r7 = 68e782c8d06635f2db4dd69b9ca8599f99da22e2 (git-svn)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   674
  No changes between current HEAD and refs/remotes/git-svn
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   675
  Resetting to the latest refs/remotes/git-svn
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   676
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   677
See what going to SVN repo::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   678
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   679
    $ cd $HOME/tmp/svn-devel/trunk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   680
    $ svn diff -r BASE:HEAD
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   681
  Index: Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   682
  ===================================================================
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   683
  --- Makefile    (working copy)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   684
  +++ Makefile    (revision 7)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   685
  @@ -6,4 +6,4 @@
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   686
   .o: .c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   687
      $(CC) $(CFLAGS) -c -o $@ $<
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   688
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   689
  -.PHONY: clean
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   690
  +.PHONY: all clean
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   691
  Index: main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   692
  ===================================================================
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   693
  --- main.c  (working copy)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   694
  +++ main.c  (revision 7)
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   695
  @@ -2,3 +2,4 @@
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   696
   {
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   697
       return 0;
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   698
   }
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   699
  +int foo(int x) {return x+x;}
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   700
    $ svn up
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   701
  U    Makefile
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   702
  U    main.c
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   703
  Updated to revision 7.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   704
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   705
gitk.
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   706
=====
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   707
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   708
gitk - The git repository browser. See gitk(1).
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   709
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   710
Installing::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   711
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   712
  $ sudo apt-get instal gitk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   713
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   714
Using::
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   715
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   716
  $ cd /path/to/git-repo
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   717
  $ gitk
234cd58cae56 Fix RTS syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
   718