Professional Documents
Culture Documents
03 Git Immersion
03 Git Immersion
03 Git Immersion
GIT/Gerrit know-how
GIT training agenda
Introduction
Setup & First commit
Three states & Basic workflow
History and old revisions
Fix mistakes
Undoing local changes
Undoing staged changes
Undoing committed changes
Amending changes
Git internals
Branching
Resolving conflicts
Merge
Rebase
Cherry-pick
Rewriting history
Multiple repositories
Tips & tricks
Up to this point we have been working with a single git repository. However,
git excels at working with multiple repositories.
These extra repositories may be stored locally, or may be accessed across
a network connection.
If a project has already been set up in a central repository, the git clone
command is the most common way for users to obtain a development
copy.
Like git init, cloning is generally a one-time operation - once a
developer has obtained a working copy, all version control operations and
collaborations are managed through their local repository.
Repo-To-Repo Collaboration
It’s important to understand that Git’s idea of a ―working copy‖ is very different from the
working copy you get by checking out code from an SVN repository.
Unlike SVN, Git makes no distinction between the working copy and the central repository—
they are all full-fledged Git repositories.
This makes collaborating with Git fundamentally different than with SVN.
Whereas SVN depends on the relationship between the central repository and the working
copy, Git’s collaboration model is based on repository-to-repository interaction.
Instead of checking a working copy into SVN’s central repository, you push or pull commits
from one repository to another.
Of course, there’s nothing stopping you from giving certain Git repos
special meaning.
For example, by simply designating one Git repo as the ―central‖ repository,
it’s possible to replicate a Centralized workflow using Git. The point is, this
is accomplished through conventions rather than being hardwired into the
VCS itself.
CONFIDENTIAL – Reproduction prohibited without the prior permission of RT-RK 5
GIT training – Git clone (3/4)
Now we see that the remote repository ―origin‖ is simply the original
repository. Remote repositories typically live on a separate machine,
possibly a centralized server. As we can see here, however, they can just
as well point to a repository on the same machine. There is nothing
particularly special about the name ―origin‖, however the convention is to
use the name ―origin‖ for the primary centralized repository (if there is one).
CONFIDENTIAL – Reproduction prohibited without the prior permission of RT-RK 8
GIT training – Remote branches (1/2)
Remote branches, are branches from remote repository. Now git branch
-a command makes a lot of sense:
lukic@gtv02-lin-$ git branch -a
* dev-lukic
remotes/origin/HEAD -> origin/dev-lukic
remotes/origin/dev-lukic
remotes/origin/dev-lukic2
remotes/origin/dev-lukic3
remotes/origin/master
[~/git/clone]
lukic@gtv02-lin-$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = /home/lukic/git/clone/../project/.git/
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "dev-lukic"]
remote = origin
merge = refs/heads/dev-lukic
It is good practice to name local branches with prefix that has ―local_‖ in
the name.
From now on, this branch has the same functionality as any other.
Beside origin repository you can work with other remote repositories
To add new remote repository to your local track use following command:
To remove remote repository from your local track use following command:
git pull perform update of remote references and merge them to local
tracking branches
You can do only update of remote references and merge it manually with
git fetch
git fetch is necessary when you add new remote repository, because
adding repository don’t download remote references
Branches advancing
git fetch may also fetch new tags if they have appeared in the remote
repository.
Introduction
Setup & First commit
Three states & Basic workflow
History and old revisions
Fix mistakes
Undoing local changes
Undoing staged changes
Undoing committed changes
Amending changes
Git internals
Branching
Resolving conflicts
Merge
Rebase
Cherry-pick
Rewriting history
Multiple repositories
Tips & tricks
Deleting branches:
git branch -D <branch name>
Dry run - Allows you to run command, in ―try‖ mode, before actually doing
it. It can be added to some git commands:
git push origin dev:remote --dry-run
git blame <file> command - Can be used to see who and when
(which commit) changed the file in the repository (per line)
f2af00bf (Ian Rickards 2009-04-21 17:32:36 -0400 29) #ifdef HAVE_CONFIG_H
f2af00bf (Ian Rickards 2009-04-21 17:32:36 -0400 30) #include <config.h>
f2af00bf (Ian Rickards 2009-04-21 17:32:36 -0400 31) #endif
f2af00bf (Ian Rickards 2009-04-21 17:32:36 -0400 32)
78faaa58 (Jonathan Morton 2009-06-03 10:43:41 -0400 33) #include <string.h>
10aa3231 (Siarhei Siamashka 2009-06-27 11:56:38 +0300 34) #include "pixman-private.h"
c1e8d453 (Siarhei Siamashka 2010-03-22 18:51:54 +0200 35) #include "pixman-arm-common.h"
f2af00bf (Ian Rickards 2009-04-21 17:32:36 -0400 36)
c1e8d453 (Siarhei Siamashka 2010-03-22 18:51:54 +0200 37) PIXMAN_ARM_BIND_FAST_PATH_SRC_DST (neon, src_8888_
c1e8d453 (Siarhei Siamashka 2010-03-22 18:51:54 +0200 38) uint32_t, 1, ui
This makes traversing through repository, with one-line log, much more
efficient:
git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
http://msysgit.github.io/
www.rt-rk.com
info@rt-rk.com