Delete remove branch:
http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely
http://stackoverflow.com/questions/1072171/how-do-you-remove-an-invalid-remote-branch-reference-from-git
Concept:
Git objects are the actual data of Git, the main thing that the reposi-
tory is made up of.
Git object data is a directed acyclic graph.
Git object contents are immutable. However, the data type insides
the object, e.g as a reference, is actually a pointer. The pointer's content can change,
points to different git object. E.g a branch, tag, and remote are references.
There are four main object types in Git:
Blob It is the contents that are stored, not the files.
Tree Contains a list of trees and blobs, along
with the names and modes of those trees and blobs.
Commit Points to a tree and keeps an author, committer, message and any parent commits that directly preceded it.
Most times a commit will only have a single parent like that, but if you merge two branches, the next commit will
point to both of them.
Tag Provides a permanent shorthand name for a particular commit.
All of these types of objects are stored in the Git Object Database,
which is kept in the Git Directory. Each object is compressed (withZlib)
and referenced by the SHA-1 value of its contents plus a small header.
Branch:
A branch in Git is nothing more than a file in the .git/refs/heads/ directory that contains
the SHA-1 of the most recent commit of that branch.
To branch that line of development, all Git does is create a new file in that directory that points
to the same SHA-1. As you continue to commit, one of the branches will keep changing to
point to the new commit SHA-1s, while the other one can stay where it was.
in Git the act of creating a new branch is simply writing a file in the .git/
refs/heads.
Creating a branch is nothing more than just writing 40 characters to a file.
Remotes:
Remotes are basically pointers to branches in other peoples copies of the same repository, often on
other computers.
Rebasing:
Treeish:
date spec:
master@{yesterday}
master@{1 month ago}
ordinal spec:
master@{5} #fifth prior value of the master branch.
carrot parent:
e65s46^2 #second parent of this commit.
master^2
tilde spec:
e65s46~5 #5th generation grandparent of that commit.
e65s46^^^^^
tree pointer:
e65s46^{tree} # This points to the tree of that commit. Any time you add a ^{tree}
to any commit-ish, it resolves to its tree.
blob spec:
master:/path/to/file #This is very helpful for referring to a blob under a particular commit or tree.
Git Directory:
Env variable:
GIT_DIR
.git/config:
1. this file
2. ~/.gitconfig
3. /etc/gitconfig
.git/index:
1. can be override with GIT_INDEX
.git/objects/:
1. all the contents of the files you have ever checked in, plus your commit, tree and tag objects.
.git/refs/:
1. heads, remotes and tags.
.git/HEAD:
1. This file holds a reference to the branch you are currently on.
2. This basically tells Git what to use as the parent of your next commit.
.git/hooks:
1. This directory contains shell scripts that are invoked after the Git commands they are named after.
Concept:
If you check out a different branch, Git will make your working directory
look like that branch, removing any checked in content that is currently in
your working directory that is not in the new tree.
This is why Git will only let you checkout another branch if everything is checked
in – there are no uncommitted modified files.
The reason for this is that Git will remove files that are not necessary in the branch
you are checking out – it needs to make sure that you can get them back again.
Commands:
Info:
$ git config --global user.name “xxx xxx”
$ git config --global user.email xxx@abc.com”
init:
$ git init
status:
$ git status
branch:
$ git branch newfunc; git checkout newfunc
$ git checkout -b newfunc
clone:
$ git clone ssh://shchang@review.ec.eng.xxx.com:29418/xxx
submodule:
$ git submodule update --init
$ git submodule update
checkout:
$ git checkout -b develop origin/develop
Commit:
$ git commit --amend --no-edit
merge:
$ git merge newfunc
undo a merge:
$ git reset --hard HEAD
$ git reset --hard ORIG_HEAD
Rebasing:
$ git rebase master
Stashing:
$ git stash
$ git stash list
$ git stash show stash@{1}
$ git diff stash@{1}
$ git stash apply stash@{1}
Stash Error reverse:
$ git reset --mixed
list conflict files:
$ git diff --name-only --diff-filter=U
clean:
remove all the untracked files in your working directory: $ git clean -f -d
reset:
$ git reset --hard HEAD~2
Get latest file from repository:
http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull
http://stackoverflow.com/questions/692246/undo-working-copy-modifications-of-one-file-in-git
$ git fetch --all
$ git reset --hard origin/master
add only modified files:
$ git ls-files --modified | xargs git add
Show name:
$ git shortlog -sne
show file changed in this patch:
$ git show --pretty="format:" --name-only xxx
Tagging:
$ git tag -a v0.1 -m ‘this is my v0.1 tag’
Lightweight Tags:
$ git tag v0.1
garbage collection:
$ git config --global gc.auto 1
$ git gc
Fetching and Pulling:
$ git fetch # simply fetch the remove origin
$ git fetch origin
$ git pull origin/story84
$ git fetch origin/story84; git merge origin/story84
Pushing:
$ git push origin master
$ git push origin HEAD:refs/for/develop
Multiple Remotes:
$ git remote add mycap git@github.com:schacon/capistrano.git
$ git remote add official git://github.com/jamis/capistrano.git
$ git fetch official
$ git merge official/master
$ git push mycap master
log:
$ git log
$ git log --pretty=oneline
$ git log -n 30 --since=”1 month ago” --until=yesterday --author=”jsc”
show:
$ git show master^
show trees:
$ git ls-tree master^{tree}
$ git ls-tree -r -t master^{tree}
show blobs:
$ git cat-file -t ae850bd698b2b5dfbac
search:
$ git grep -n ‘log_syslog’ v1.5.3.8 v1.0.0 -- *.c
diff:
$ git diff
$ git diff a11bef06a3f65..cf25cc3bfb0 -- Rakefile
Generating Patch Files:
$ git diff master..experiment > experiment.patch
$ patch -p1 < ~/experiment.patch
Hook Script:
$ curl -Lo .git/hooks/commit-msg http://review.ec.eng.xxx.com/tools/hooks/commit-msg
$ chmod +x .git/hooks/commit-msg
Rename:
$ git branch -m old_branch new_branch # Rename branch locally
$ git push origin :old_branch # Delete the old branch
$git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
reference:
https://gist.github.com/lttlrck/9628955
Find this branch's forked from:
$ git branch --contains $(git merge-base this_branch_name base_branch_name)
reference:
http://stackoverflow.com/questions/4803492/how-can-i-see-what-branch-another-branch-was-forked-from
Reference:
15 trick u should know about git
github section:
rebase original project forked from
$ git remote add upstream https://github.com/whoever/whatever.git
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
http://stackoverflow.com/a/7244456
git blame:
http://superuser.com/questions/261588/gnu-sort-and-git-blame
$ git blame file | sort -b -k 3
git file change:
$ git log -p -- test.go
$ git diff file between commits:
$ git diff [--options] <commit> <commit> [--] [<path>...]
https://git-scm.com/docs/git-bisect
$ git bisect start
$ git bisect bad 887313f9833c556f701be5991faecdd4bdd2f1af # last bad
$ git bisect good fe2a0afef20b2da348d19251fff8fa5989dfc6e1 # early known as good
Reset
$ git bisect reset
$ git bisect reset <commit>
https://stacktoheap.com/blog/2016/01/19/using-multiple-worktrees-with-git/
$ git worktree add -b BUGFIX ../bugfix origin/master
$ git worktree add --detach ../project-build HEAD
clean up
$ rm -rf ../BUGFIX && git worktree prune
http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely
http://stackoverflow.com/questions/1072171/how-do-you-remove-an-invalid-remote-branch-reference-from-git
Concept:
Git objects are the actual data of Git, the main thing that the reposi-
tory is made up of.
Git object data is a directed acyclic graph.
Git object contents are immutable. However, the data type insides
the object, e.g as a reference, is actually a pointer. The pointer's content can change,
points to different git object. E.g a branch, tag, and remote are references.
There are four main object types in Git:
Blob It is the contents that are stored, not the files.
Tree Contains a list of trees and blobs, along
with the names and modes of those trees and blobs.
Commit Points to a tree and keeps an author, committer, message and any parent commits that directly preceded it.
Most times a commit will only have a single parent like that, but if you merge two branches, the next commit will
point to both of them.
Tag Provides a permanent shorthand name for a particular commit.
All of these types of objects are stored in the Git Object Database,
which is kept in the Git Directory. Each object is compressed (withZlib)
and referenced by the SHA-1 value of its contents plus a small header.
Branch:
A branch in Git is nothing more than a file in the .git/refs/heads/ directory that contains
the SHA-1 of the most recent commit of that branch.
To branch that line of development, all Git does is create a new file in that directory that points
to the same SHA-1. As you continue to commit, one of the branches will keep changing to
point to the new commit SHA-1s, while the other one can stay where it was.
in Git the act of creating a new branch is simply writing a file in the .git/
refs/heads.
Creating a branch is nothing more than just writing 40 characters to a file.
Remotes:
Remotes are basically pointers to branches in other peoples copies of the same repository, often on
other computers.
Rebasing:
Treeish:
date spec:
master@{yesterday}
master@{1 month ago}
ordinal spec:
master@{5} #fifth prior value of the master branch.
carrot parent:
e65s46^2 #second parent of this commit.
master^2
tilde spec:
e65s46~5 #5th generation grandparent of that commit.
e65s46^^^^^
tree pointer:
e65s46^{tree} # This points to the tree of that commit. Any time you add a ^{tree}
to any commit-ish, it resolves to its tree.
blob spec:
master:/path/to/file #This is very helpful for referring to a blob under a particular commit or tree.
Git Directory:
Env variable:
GIT_DIR
.git/config:
1. this file
2. ~/.gitconfig
3. /etc/gitconfig
.git/index:
1. can be override with GIT_INDEX
.git/objects/:
1. all the contents of the files you have ever checked in, plus your commit, tree and tag objects.
.git/refs/:
1. heads, remotes and tags.
.git/HEAD:
1. This file holds a reference to the branch you are currently on.
2. This basically tells Git what to use as the parent of your next commit.
.git/hooks:
1. This directory contains shell scripts that are invoked after the Git commands they are named after.
Concept:
If you check out a different branch, Git will make your working directory
look like that branch, removing any checked in content that is currently in
your working directory that is not in the new tree.
This is why Git will only let you checkout another branch if everything is checked
in – there are no uncommitted modified files.
The reason for this is that Git will remove files that are not necessary in the branch
you are checking out – it needs to make sure that you can get them back again.
Commands:
Info:
$ git config --global user.name “xxx xxx”
$ git config --global user.email xxx@abc.com”
init:
$ git init
status:
$ git status
branch:
$ git branch newfunc; git checkout newfunc
$ git checkout -b newfunc
clone:
$ git clone ssh://shchang@review.ec.eng.xxx.com:29418/xxx
submodule:
$ git submodule update --init
$ git submodule update
checkout:
$ git checkout -b develop origin/develop
Commit:
$ git commit --amend --no-edit
merge:
$ git merge newfunc
undo a merge:
$ git reset --hard HEAD
$ git reset --hard ORIG_HEAD
Rebasing:
$ git rebase master
Stashing:
$ git stash
$ git stash list
$ git stash show stash@{1}
$ git diff stash@{1}
$ git stash apply stash@{1}
Stash Error reverse:
$ git reset --mixed
list conflict files:
$ git diff --name-only --diff-filter=U
clean:
remove all the untracked files in your working directory: $ git clean -f -d
reset:
$ git reset --hard HEAD~2
Get latest file from repository:
http://stackoverflow.com/questions/1125968/force-git-to-overwrite-local-files-on-pull
http://stackoverflow.com/questions/692246/undo-working-copy-modifications-of-one-file-in-git
$ git fetch --all
$ git reset --hard origin/master
add only modified files:
$ git ls-files --modified | xargs git add
Show name:
$ git shortlog -sne
show file changed in this patch:
$ git show --pretty="format:" --name-only xxx
Tagging:
$ git tag -a v0.1 -m ‘this is my v0.1 tag’
Lightweight Tags:
$ git tag v0.1
garbage collection:
$ git config --global gc.auto 1
$ git gc
Fetching and Pulling:
$ git fetch # simply fetch the remove origin
$ git fetch origin
$ git pull origin/story84
$ git fetch origin/story84; git merge origin/story84
Pushing:
$ git push origin master
$ git push origin HEAD:refs/for/develop
Multiple Remotes:
$ git remote add mycap git@github.com:schacon/capistrano.git
$ git remote add official git://github.com/jamis/capistrano.git
$ git fetch official
$ git merge official/master
$ git push mycap master
log:
$ git log
$ git log --pretty=oneline
$ git log -n 30 --since=”1 month ago” --until=yesterday --author=”jsc”
show:
$ git show master^
show trees:
$ git ls-tree master^{tree}
$ git ls-tree -r -t master^{tree}
show blobs:
$ git cat-file -t ae850bd698b2b5dfbac
search:
$ git grep -n ‘log_syslog’ v1.5.3.8 v1.0.0 -- *.c
diff:
$ git diff
$ git diff a11bef06a3f65..cf25cc3bfb0 -- Rakefile
Generating Patch Files:
$ git diff master..experiment > experiment.patch
$ patch -p1 < ~/experiment.patch
Hook Script:
$ curl -Lo .git/hooks/commit-msg http://review.ec.eng.xxx.com/tools/hooks/commit-msg
$ chmod +x .git/hooks/commit-msg
Rename:
$ git branch -m old_branch new_branch # Rename branch locally
$ git push origin :old_branch # Delete the old branch
$git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
reference:
https://gist.github.com/lttlrck/9628955
Find this branch's forked from:
$ git branch --contains $(git merge-base this_branch_name base_branch_name)
reference:
http://stackoverflow.com/questions/4803492/how-can-i-see-what-branch-another-branch-was-forked-from
Reference:
15 trick u should know about git
github section:
rebase original project forked from
$ git remote add upstream https://github.com/whoever/whatever.git
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
http://stackoverflow.com/a/7244456
git blame:
http://superuser.com/questions/261588/gnu-sort-and-git-blame
$ git blame file | sort -b -k 3
git file change:
$ git log -p -- test.go
$ git diff file between commits:
$ git diff [--options] <commit> <commit> [--] [<path>...]
https://git-scm.com/docs/git-bisect
$ git bisect start
$ git bisect bad 887313f9833c556f701be5991faecdd4bdd2f1af # last bad
$ git bisect good fe2a0afef20b2da348d19251fff8fa5989dfc6e1 # early known as good
Reset
$ git bisect reset
$ git bisect reset <commit>
https://stacktoheap.com/blog/2016/01/19/using-multiple-worktrees-with-git/
$ git worktree add -b BUGFIX ../bugfix origin/master
$ git worktree add --detach ../project-build HEAD
clean up
$ rm -rf ../BUGFIX && git worktree prune
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.