GitHub 使用案例 2

Git版本管理

簡介

安裝

命令

GitHub

GoogleCode

TortoiseGit

訊息

相關網站

參考文獻

最新修改

簡體版

English

這次使用的是 git bash 介面:

參考:http://stackoverflow.com/questions/10298291/cannot-pushto-github-keeping-saying-need-merge

use git pull origin master before you push anything.

Welcome to Git (version 1.8.0-preview20121022)

Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

ccckmit@CCCKMIT-PC ~
$ ls
AppData
Application Data
Contacts
Cookies
Desktop
Documents
Downloads
Dropbox
Favorites
Links
Local Settings
Music
My Documents
NTUSER.DAT
NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TM.blf
NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TMContainer00000000000000000001
.regtrans-ms
NTUSER.DAT{016888bd-6c6f-11de-8d1d-001e0bcde3ec}.TMContainer00000000000000000002
.regtrans-ms
NetHood
Pictures
PrintHood
Recent
Saved Games
Searches
SendTo
Templates
Videos
[??????] ?????????
ntuser.dat.LOG1
ntuser.dat.LOG2
ntuser.ini

ccckmit@CCCKMIT-PC ~
$ g:
sh.exe": g:: command not found

ccckmit@CCCKMIT-PC ~
$ git help
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info
-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

See 'git help <command>' for more information on a specific command.

ccckmit@CCCKMIT-PC ~
$ pwd
/c/Users/ccckmit

ccckmit@CCCKMIT-PC ~
$ cd /g

ccckmit@CCCKMIT-PC /g
$ cd code

ccckmit@CCCKMIT-PC /g/code
$ ls
cl

ccckmit@CCCKMIT-PC /g/code
$ cd cl

ccckmit@CCCKMIT-PC /g/code/cl
$ ls
ch2  ch3  ch4

ccckmit@CCCKMIT-PC /g/code/cl
$ git init
Initialized empty Git repository in g:/code/cl/.git/

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git add --all

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git config --global user.name "ccckmit"

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git commit -m "first commit"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'ccckmit@ccckmit-PC.(none)')

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git config --global user.email "ccckmit@gmail.com"

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git commit -m "first commit"
[master (root-commit) 16386af] first commit
 36 files changed, 427 insertions(+)
 create mode 100644 ch2/gchinese.c
 create mode 100644 ch2/gchinese.exe
 create mode 100644 ch2/genglish.c
 create mode 100644 ch2/genglish.exe
 create mode 100644 ch2/gexp.c
 create mode 100644 ch2/gexp.exe
 create mode 100644 ch2/gfloat.c
 create mode 100644 ch2/gfloat.exe
 create mode 100644 ch2/gint.c
 create mode 100644 ch2/gint.exe
 create mode 100644 ch2/rlib.c
 create mode 100644 ch3/big5dump.c
 create mode 100644 ch3/big5dump.exe
 create mode 100644 ch3/big5print.c
 create mode 100644 ch3/big5print.exe
 create mode 100644 ch3/mbstowcs.c
 create mode 100644 ch3/mbstowcs.exe
 create mode 100644 ch3/s.txt
 create mode 100644 ch3/t.txt
 create mode 100644 ch3/t2.txt
 create mode 100644 ch3/t2s.txt
 create mode 100644 ch3/trans.c
 create mode 100644 ch3/trans.exe
 create mode 100644 ch3/unicode.c
 create mode 100644 ch3/unicode.txt
 create mode 100644 ch3/uniread.c
 create mode 100644 ch3/uniread.exe
 create mode 100644 ch3/unitest.c
 create mode 100644 ch3/unitest.exe
 create mode 100644 ch4/cedict_log.u16le
 create mode 100644 ch4/cedict_ts.u16le
 create mode 100644 ch4/cedictparse.c
 create mode 100644 ch4/cedictparse.exe
 create mode 100644 ch4/escan.c
 create mode 100644 ch4/escan.exe
 create mode 100644 ch4/unicode.c

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git remote add origin https://github.com/ccckmit/mathnode.git

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git remote add origin https://github.com/ccckmit/ComputationalLinguistics.git
fatal: remote origin already exists.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git remote rm origin

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git remote add origin https://github.com/ccckmit/ComputationalLinguistics.git

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git push -u origin master
Username for 'https://github.com': ccckmit
Password for 'https://ccckmit@github.com':
To https://github.com/ccckmit/ComputationalLinguistics.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/ccckmit/ComputationalLing
uistics.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git pull -A
error: unknown switch `A'
usage: git fetch [<options>] [<repository> [<refspec>...]]
   or: git fetch [<options>] <group>
   or: git fetch --multiple [<options>] [(<repository> | <group>)...]
   or: git fetch --all [<options>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --all                 fetch from all remotes
    -a, --append          append to .git/FETCH_HEAD instead of overwriting
    --upload-pack <path>  path to upload pack on remote end
    -f, --force           force overwrite of local branch
    -m, --multiple        fetch from multiple remotes
    -t, --tags            fetch all tags and associated objects
    -n                    do not fetch all tags (--no-tags)
    -p, --prune           prune remote-tracking branches no longer on remote
    --recurse-submodules[=<on-demand>]
                          control recursive fetching of submodules
    --dry-run             dry run
    -k, --keep            keep downloaded pack
    -u, --update-head-ok  allow updating of HEAD ref
    --progress            force progress reporting
    --depth <depth>       deepen history of shallow clone

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git pull --all
Fetching origin
warning: no common commits
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/ccckmit/ComputationalLinguistics
 * [new branch]      master     -> origin/master
You asked to pull from the remote '--all', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git push -u origin master
Username for 'https://github.com': ccckmit
Password for 'https://ccckmit@github.com':
To https://github.com/ccckmit/ComputationalLinguistics.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/ccckmit/ComputationalLing
uistics.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git config --global user.email "ccckmit@github.com"

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git push -u origin master
Username for 'https://github.com': ccckmit
Password for 'https://ccckmit@github.com':
To https://github.com/ccckmit/ComputationalLinguistics.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/ccckmit/ComputationalLing
uistics.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git pull origin master
From https://github.com/ccckmit/ComputationalLinguistics
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 README.md

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ ls
README.md  ch2  ch3  ch4

ccckmit@CCCKMIT-PC /g/code/cl (master)
$ git push -u origin master
Username for 'https://github.com': ccckmit
Password for 'https://ccckmit@github.com':
Counting objects: 42, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (41/41), 4.93 MiB | 68 KiB/s, done.
Total 41 (delta 14), reused 0 (delta 0)
To https://github.com/ccckmit/ComputationalLinguistics.git
   9064a44..7d04f27  master -> master
Branch master set up to track remote branch master from origin.

ccckmit@CCCKMIT-PC /g/code/cl (master)
$

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License