

拷貝一份Git,向更改他的遠程倉庫,同時保存原來的log |
git push --mirror git@git.oschina.net:【名字】/ListViewAnimation.git 從劉俊偉拷貝的ListViewAnimation,保存了他的修改,現在遠程git是自己的
|
1:在本地創建了Eclipse/AndroidStudio/Idea ..工程 或者任意文件夾子 將該目錄創建為git倉庫 git init 得到一個git倉庫,可以進行git add /git commit 等操作 2:在github 或者 git.oschina.net 創建了遠程倉庫 3:欲將本地倉庫托管到遠程 git remote add origin URL 4.在本地增加了新的分支branch_2,欲將該分支同步到托管服務器 git push orign branch_2
|
|
$ git push No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'. fatal: The remote end hung up unexpectedly error: failed to push some refs to '/work/fun/git_experiments/bare' the problem is that there are no commits in "bare". This is a problem with the first commit only, if you create the repos in the order (bare,alice). Try doing |
|
dss886@dss886-OptiPlex-3020:~/testgit/server$ git status
fatal: Not a git repository (or any parent up to mount point /home) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). |
當前目錄不是一個git,不是一個倉庫(但是他的子目錄可以是git /倉庫) | ||
dss886@dss886-OptiPlex-3020:~/testgit/server$ git status 位於分支 master 無文件要提交,干凈的工作區 |
當前目錄或者當前倉庫 所有內容都被提交到倉庫(實際上是一種記錄)
也就是更新到了最新
|
||
Git hub |
dss886@dss886-OptiPlex-3020:~/testgit$ mkdir github
dss886@dss886-OptiPlex-3020:~/testgit$ cd github/
<之前配置了在樂視代碼托管服務器上的賬戶 key
改賬戶無法在github上使用 當然了22222>
dss886@dss886-OptiPlex-3020:~/testgit/github$ git clone git@github.com:cghGit/bootstrap.git 正克隆到 'bootstrap'... The authenticity of host 'github.com (192.30.252.128)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. |
||
同一客戶端多個git賬號的配置
http://my.oschina.net/csensix/blog/184434
http://blog.csdn.net/five3/article/details/8904635
|
步驟一:用ssh-keygen命令生成一組新的id_rsa_new和id_rsa_new.pub。 平時我們都是直接回車,默認生成id_rsa和id_rsa.pub。這里特別需要注意,出現提示輸入文件名的時候要輸入與默認配置不一樣的文件名,比如: id_rsa_new。 步驟二:配置~/.ssh/config文件,以我自己的機器為例。 Host就是每個SSH連接的單獨代號,IdentityFile告訴SSH連接去讀取哪個私鑰。 步驟三:執行ssh-agent讓ssh識別新的私鑰。 該命令如果報錯:Could not open a connection to your authentication agent.無法連接到ssh agent,可執行ssh-agent bash命令后再執行ssh-add命令。 以后,在clone或者add remote的時候,需要把config文件中的host代替git@remoteaddress中的remoteaddress。 同時,你可以通過在特定的repo下執行下面的命令,生成區別於全局設置的user.name和user.email。 例子: 上面的兩條clone命令,雖然關聯到同一個repo,卻是通過不同ssh連接,當然也是不同的git賬號。
=============================================================================================
在linux下搭建git環境
1、創建Github賬號,https://github.com 2、Linux創建SSH密鑰:
4,修改文件 .ssh/config
添加
Host mygit1
User conncuiGIT //github 用戶名
Hostname github.com
IdentityFile 第一步生成的密鑰文件地址
5:ssh-add 私鑰目錄
5、測試驗證是否成功。
同步github到本地 1、復制項目到本地:
本地提交項目到github 1、本地配置
分支版本操作 1、創建和合並分支
git命令使用思維圖:【非常有料】 |
||
smartgit 圖形化界面工具 |
下載后 在解壓目錄下/bin 中的smartgithg.sh 設置smartgit 的運行環境(要求 1.7)
if [ "$SMARTGITHG_JAVA_HOME" = "" ] ; then SMARTGITHG_JAVA_HOME=$SMARTGIT_JAVA_HOME fi if [ "$SMARTGITHG_JAVA_HOME" = "" ] && [ -f "/usr/lib/jvm/java-7-openjdk-i386/jre/bin/java" ] ; then SMARTGITHG_JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386/jre" fi if [ "$SMARTGITHG_JAVA_HOME" = "" ] ; then SMARTGITHG_JAVA_HOME=$JAVA_HOME fi if [ "$SMARTGITHG_MAX_HEAP_SIZE" = "" ] ; then SMARTGITHG_MAX_HEAP_SIZE=$SMARTGIT_MAX_HEAP_SIZE fi if [ "$SMARTGITHG_MAX_HEAP_SIZE" = "" ] ; then SMARTGITHG_MAX_HEAP_SIZE=256m fi SMARTGITHG_JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
||
本地代碼庫回滾 |
git reset --hard commit-id :回滾到commit-id,講commit-id之后提交的commit都去除
|
還有的時候,你希望查看某個指定文件的提交歷史。譬如你希望查看'notes.c'文件每一次的提交歷史
|
$
git log --pretty=oneline -- file |
用git管理Andoird Studio,IntellJieda時,ide產生大量的臨時文件(gradle,build...)這些文件沒有必要納入git管理,所有用文件 .gitignore 來標記不納入git的文件,文件夾 | build : .gitignore 所在父目錄下的所有build 將被忽略 /build:.gitignore 所在同等目錄下的build .class :所有后綴為class 的文件
問題: 利用.gitignore過濾文件,如編譯過程中的中間文件,等等,這些文件不需要被追蹤管理。 現象:文件,以過濾該文件,但是通過git status查看仍顯示file1文件的狀態。 原因: 在git庫中已存在了這個文件,之前push提交過該文件。 .gitignore文件只對還沒有加入版本管理的文件起作用,如果之前已經用git把這些文件納入了版本庫,就不起作用了 解決: 需要在git庫中刪除該文件,並更新。 然后再次git status查看狀態,file1文件不再顯示狀態。 ci@clinux:~/c/CuiDemo/studio/StudioProject$ git rm -r build error: 如下文件有本地修改: StudioProject/build/intermediates/dex-cache/cache.xml (使用 --cached 保留本地文件,或用 -f 強制刪除) ci@clinux:~/c/CuiDemo/studio/StudioProject$ 請使用: ci@clinux:~/c/CuiDemo/studio/StudioProject$ git rm -r --cached build rm 'StudioProject/build/intermediates/dex-cache/cache.xml' rm 'StudioProject/build/intermediates/model_data.bin' ci@clinux:~/c/CuiDemo/studio/StudioProject$ 或者 ci@clinux:~/c/CuiDemo/studio/StudioProject$ git rm -r -f build
|
廖雪峰的官方網站 http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000 使用Git管理本地項目 http://www.linuxidc.com/Linux/2014-03/98367.htm 和菜鳥一起學linux之本地git中心倉庫建立 http://blog.csdn.net/eastmoon502136/article/details/7735957