$ sudo apt-get install git git-core
$ git config --global user.name "abcd" $ git config --global user.email abcd@efgh.com
$ ssh-keygen -t rsa -C "abcd@efgh.com" //郵箱同上
vim /home/linx/.ssh/id_rsa.pub //複製裏面的密鑰
$ ssh git@github.com //正常狀況下,回顯以下 PTY allocation request failed on channel 0 Hi plinx! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
$ mkdir tmp //建立推送目錄 $ cd tmp //進入推送目錄 $ git init //設置該目錄爲推送 $ touch README //生成readme $ git add README //加入修改列表 $ git commit -m 'first commit' //遞交修改聲明 $ git remote add origin git@github.com:abcd/tmp.git //爲遠程Git改名爲origin $ git push -u origin master //推送這次修改
ERROR: Repository not found.這個問題是由於在你推送的github帳戶中,並無這個Repository。
Agent admitted failure to sign using the key. Permission denied (publickey)這個問題是由於你的ssh key並無加入到你想git的github帳戶的ssh key中,因此沒有訪問權限。
//出現以下提示 ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ...
$ git push -f
$ git pull
[branch "master"] remote = origin merge = refs/heads/master
$ git config branch.master.remote origin $ git config branch.master.merge ref/heads/master
一、先查看當前開發分支
python
$ cat .git/HEAD ref: refs/heads/master
$ git status # On branch master nothing to commit (working directory clean)
$ git add README //以後有兩種方法填寫推送信息 //比較簡單的一種,直接寫入推送信息,-m 就是 message 的意思 $ git commit -m 'message you want to write.' //比較麻煩的一種 $ git commit //進入GNU nano編輯器,底行有操做提示
[master bc30d5d] updated the status. 1 file changed, 1 insertion(+)
# On branch master # Your branch is ahead of 'origin/master' by 1 commit. # nothing to commit (working directory clean)
$ git log
$ git diff //這項操做時要在添加推送以前執行的,不然就看不出哪裏不一樣了
git branch test0.1 //建立一個test0.1分支 git checkout test0.1 //進入這個分支中來 git branch //查看當前分支狀況,所在分支前面有'*'號 git add -A //將本次修改的全部內容都加入修改列表 git commit -m "commit all" //提交說明 git push -u origin test0.1 //將這次修改提交到分支test0.1中去
$ git commit -a $ git push -u origin code_ver0.1 //分支和帳戶請勿對號入座