1)获取远程仓库
git clone
$ git clone git@github.com:jamsonwoo/git-tutorial.git
Cloning into 'git-tutorial'...
Enter passphrase for key '/c/Documents and Settings/Administrator/.ssh/id_rsa':
remote: Counting objects: 20, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 20 (delta 3), reused 20 (delta 3), pack-reused 0
Receiving objects: 100% (20/20), done.
Resolving deltas: 100% (3/3), done.
Checking connectivity... done
$ cd git-tutorial/
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/feature-D
remotes/origin/master
$ git checkout -b feature-D origin/feature-D
Branch feature-D set up to track remote branch feature-D from origin.
Switched to a new branch 'feature-D'
$ git diff
diff --git a/README.md b/README.md
index c194c43..617cdfb 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,5 @@
- feature-A
- fix-B
- - feature-C
\ No newline at end of file
+ - feature-C
+ - feature-D
\ No newline at end of file
$ git commit -am "Add feature-D"
[feature-D 3b33297] Add feature-D
1 file changed, 2 insertions(+), 1 deletion(-)
$ git push
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 280 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:jamsonwoo/git-tutorial.git
b306656..3b33297 feature-D -> feature-D
2)获取最新的远程仓库分支
git pull
$ cd ../../git-tutorial
$ git pull origin feature-D
Enter passphrase for key '/c/Documents and Settings/Administrator/.ssh/id_rsa':
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From github.com:jamsonwoo/git-tutorial
* branch feature-D -> FETCH_HEAD
b306656..3b33297 feature-D -> origin/feature-D
Updating b306656..3b33297
Fast-forward
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)