Archive

Posts Tagged ‘Git’

Google Code 与 Github代码同步

January 26th, 2010 BianJiang No comments
git config --global user.name "Bian Jiang"
git config --global user.email borderj@gmail.com
git svn clone https://golang-china.googlecode.com/svn/trunk -s
git remote add origin git@github.com:border/golang-china.git
git push origin master
git svn rebase // 本地与Goolge Code 代码同步
git push // 上传本地的代码到github
git svn dcommit // 上传本地的代码到Google Code 

在Github上创建ssh授权参考: http://wifihack.net/blog/2008/12/permission-denied-on-github/

–EOF–
http://www.wifihack.net

Categories: Tech.Notes Tags: , , , ,

Create and push an annotated tag in Git

July 23rd, 2009 BianJiang No comments

# Create a tag on most current commit
git tag -a -m “tagging version 1.0″ v1.0

# Create a tag on a specific commit
git tag -a -m “tagging version 1.0″ v1.0 ec78b6b0778a1e02cb9554ce2dca4fcdd7a08a7d

# List tags
git tag -l

# Push tags to remote repository
git push –tags

# Push specific tag to remote repository
git push origin :tag_name

# Deleting a tag locally
git tag -d “v1.0″

# To push the deletion to remote repository
git push origin :refs/tags/v1.0

git tag options
-a
Make an unsigned, annotated tag object
-s
Make a GPG-signed tag, using the default e-mail address’s key
-u <key-id>
Make a GPG-signed tag, using the given key
-f
Replace an existing tag with the given name (instead of failing)
-d
Delete existing tags with the given names.
-v
Verify the gpg signature of the given tag names.
-l <pattern>
List tags with names that match the given pattern (or all if no pattern is given). Typing “git tag” without arguments, also lists all tags.
-m <msg>
Use the given tag message (instead of prompting). If multiple -m options are given, their values are concatenated as separate paragraphs. Implies -a if none of -a, -s, or -u <key-id> is given.

参考:
1. http://snipplr.com/view/16739/create-and-push-an-annotated-tag-in-git/
2. http://www.kernel.org/pub/software/scm/git/docs/git-push.html
3. http://www.kernel.org/pub/software/scm/git/docs/git-tag.html

Categories: Tech.Notes Tags: , ,

Git-svn workflow

April 3rd, 2009 BianJiang No comments

本文参考: http://notes.jimlindley.com/2008/3/25/git-svn-that-works-for-me
作者: Jim Lindley

The canonical git-svn workflow that I’ve seen goes like this:
标准的git-svn工作流程参考这里:

[code lang="C"]
git svn clone
git checkout -b
…hack…hack…

git commit -a
git checkout master
git merge #NOTE: no need for –squash anymore
git svn rebase
git svn dcommit -e # -e will let you enter a commit message for SVN

[/code]

I’ve had more luck with the following workflow, when integrating changes via SVN from other team members:
我从团队的其他成员学到了更好的工作流程:

[code lang="C"]
# initial setup
git svn clone

# 99% of daily workflow
git checkout -b
…hack…hack…
git commit -a

# switch back to master, then rebase against
# any revisions in the svn repo
git checkout master
git svn rebase

# now that master is current with svn,
# sync working branch to local master
git checkout # These two are the added steps
git rebase master # which help prevent conflicts

# final upstream commit after rebasing
git checkout master
git svn rebase # one last check for new svn check ins
git merge
git svn dcommit -e

[/code]

The extra rebase step seems to do a better job of integrating your patches into the tree. Merge should do the same thing, if I’m reading the man pages right, but splitting the steps is more idiot proof (me-proof) this way.

It also keeps the master local branch from getting messy dealing with conflicts. Instead conflict is kept in the side working branch.

上面虽然很罗嗦但是做的好处在于,我们把所有的工作和从svn代码的合并都放在本地的分支上进行。这样就能保证本地主干与svn服务器进行同步,并且在本地主干没有任何修改。

更多有关git, git-svn,  git-reset 的文章:
1. git-svn workflow
2. An introduction to git-svn for Subversion/SVK users and deserters
3. Git reset in depth

2009.4.3
Bian Jiang
–EOF–

Categories: Tech.Notes Tags: , , ,

Git info like svn info

March 26th, 2009 BianJiang No comments

之前用 SVN 的时候经常用 svn info 反应当前svn的基本信息,但是在Git 中没有类似的功能。

比如查看当前版本的一些基本信息:

[code lang="c"]
git remote -v
git branch -r
git branch
[/code]

每次敲很多的命令是很麻烦的,但是Hack里面力量是无限的,在 git-info.txt 有些简单的命令组合可以完成我们的需求。

运行的效果如下:

[code lang="c"]

== Remote URL: origin   git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap/linux-docs/.git
== Remote Branches:
origin/HEAD
origin/doc-subdirs
origin/master

== Local Branches:
* doc-subdirs

== Configuration (.git/config)
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap/linux-docs/.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "doc-subdirs"]
remote = origin
merge = refs/heads/doc-subdirs

== Most Recent Commit
commit 31c00fc15ebd35c1647775dbfc167a15d46657fd
Author: Randy Dunlap
Date:   Thu Nov 13 21:33:24 2008 +0000

Create/use more directory structure in the Documentation/ tree.

Create Documentation/blockdev/ sub-directory and populate it.
Populate the Documentation/serial/ sub-directory.
Move MSI-HOWTO.txt to Documentation/PCI/.
Move ioctl-number.txt to Documentation/ioctl/.
Update all relevant 00-INDEX files.
Update all relevant Kconfig files and source files.

Signed-off-by: Randy Dunlap

Type ‘git log’ for more commits, or ‘git show’ for full commit details.

[/code]

Git-info 脚本如下:

[code lang="c"]

#!/bin/bash

# author: Duane Johnson
# email: duane.johnson@gmail.com
# date: 2008 Jun 12
# license: MIT
#
# Based on discussion at http://kerneltrap.org/mailarchive/git/2007/11/12/406496

pushd . >/dev/null

# Find base of git directory
while [ ! -d .git ] &amp;amp;&amp;amp; [ ! `pwd` = "/" ]; do cd ..; done

# Show various information about this git directory
if [ -d .git ]; then
echo "== Remote URL: `git remote -v`"

echo "== Remote Branches: "
git branch -r
echo

echo "== Local Branches:"
git branch
echo

echo "== Configuration (.git/config)"
cat .git/config
echo

echo "== Most Recent Commit"
git log --max-count=1
echo

echo "Type 'git log' for more commits, or 'git show' for full commit details."
else
echo "Not a git repository."
fi

popd >/dev/null

[/code]

这里有些有关git info讨论话题。

Links:

1. Git Info (kinda like ’svn info’)  http://blog.inquirylabs.com/2008/06/12/git-info-kinda-like-svn-info/

2. git info 脚步 http://blog.inquirylabs.com/wp-content/uploads/2008/06/git-info.txt

3. KernelTrap 有关git info讨论的话题

Categories: Tech.Notes Tags: ,

Permission denied on GitHub

December 3rd, 2008 BianJiang No comments

进来在学习Git,于是在GitHub上创建了个项目,把自己常用的代码快方上去,但是在上传的时候出现授权问题.

1.按照 GitHub 上面的介绍:

mkdir border
cd border
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:border/border.git
git push origin master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

2.参照GitHub上面的Guider创建ssh授权:

border@ubuntu:~/.ssh$ ls
known_hosts
border@ubuntu:~/.ssh$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/border/.ssh/id_rsa): <enter>
Enter passphrase (empty for no passphrase): <enter>
Enter same passphrase again: <enter>
Your identification has been saved in /home/border/.ssh/id_rsa.
Your public key has been saved in /home/border/.ssh/id_rsa.pub.
The key fingerprint is:
6d:15:80:df:07:7c:9a:fc:79:60:1d:4e:60:f5:80:0f border@ubuntu
border@ubuntu:~/.ssh$ ls
id_rsa id_rsa.keystore id_rsa.pub known_hosts

3.把文件id_rsa.pub 中的Key复制到GitHub帐户管理上:

a.复制~/.ssh/id_rsa.pub文件内容到剪切板上.
b.在浏览器 github > account -> add another public key 中添上你刚刚复制的内容,Title可以随便添,并保存.
c.返回.ssh 目录执行 ssh-add 命令。
d.现在你可以把你的 README push 到 GitHub上了.
参考:
  1. http://github.com/guides/providing-your-ssh-key#linux

–EOF–

Categories: Tech.Notes Tags: ,