廣告

顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2016年8月7日 星期日

[git]Untrack files from git

This will tell git you want to start ignoring the changes to the file
git update-index --assume-unchanged path/to/file

When you want to start keeping track again
git update-index --no-assume-unchanged path/to/file

usage occasion : put some file in remote once and not track it anymore

                 ex:local config

2015年10月23日 星期五

Change the URI (URL) for a remote Git repository | 修改git remote的網址

有兩個方法:
1. edit .git/config and change the URLs there.

2. git remote set-url origin git://new.url.here


================================
show current remote url
git config --get remote.origin.url

2015年4月16日 星期四

[git] The step of release production code to remote


#project一開始會有兩條branch,
#master(主要開發用) & release(上版用)
#開branch
 git branch release

#push release這個分支 
 #ex:git push origin release
 
#每次要上版

1.merge master to release 
  git merge release maste

2.push to remote
  git push

3.(add tag 會add到當前你在的分支)  
git tag $release-versioNname
 #ex:git tag v1.1.1

git push $repository_name $release-versioNname
 #ex:git push origin v1.1.1

2015年4月9日 星期四

[git] clone specific version & push branch to remote

事情是這樣的.
每次上板前都應該branch一個版本出來
並且push 到server.
樣樣revert比較快.





clone specific version from remote
$ git clone $URL
$ git reset --hard $SHA1
  EX:git reset --hard 5201870025b316252008882aecbd2e2fd8d68787

To again go back to the most recent commit
$ git pull


push branch to remote
$ git remote -v
  shows remote repository name and url
  
//基於此版本 branch 一個 版本出來
$ git branch branch_name

切換 branch
$ git check branch_name

push branch
$ git push repository_name branch_name

2015年4月5日 星期日

[git] diff : add . & add -u & add -A


先新增三個檔案當作測試用

after_modify.txt
new_add.txt
deleted.txt

並且都git add
==========================
git rm deleted.txt

修改after_modify.txt內容


此時看status如下


git add . 
結果如下:
會發現 deleted.txt 沒有近來


========================== git reset ==========================
git add -u
結果如下:
圖

會發現 new_add.txt 沒有近來

========================== git reset ==========================
git add -A
結果如下:


全都進來了



總結一下:
git add -A :全都進到stages
git add .  :git rm 的會沒有 
git add -u :新增的檔案沒有

[git] 基本git使用 tutirial 2 (branch, merge)


gitk --all //圖形化介面

git branch //列出目前所有branch

git checkout -b issue513  // 由現在的環境為基礎, 建立新的 branch

git checkout issue513 //切換branch


在 branch新增 檔案
並且 add , then commit.


切回 master
git checkout master

merge:
git merge issue513


[git] 不錯的git教學

因為我這邊都只記錄自己常用到的部分,
所以這邊貼上一些當初參考的連結。

http://gogojimmy.net/2012/01/17/how-to-use-git-1-git-basic/

http://blog.longwin.com.tw/2009/05/git-learn-initial-command-2009/

http://backlogtool.com/git-guide/tw/reference/log.html

https://ihower.tw/blog/archives/2622

2015年3月28日 星期六

[git] 基本git使用 tutirial 1 (add, commit, push, pull)

由於最近我們team的版本控管要從SVN轉為git,
所以想說寫個基本的git的筆記,
之前都是用github的gui所以對一些commamd還不太熟,
雖然eclipse也支援git的功能,
不過還是練習一下command吧!!

但礙於公司規定所以每晚還是要將git
同步到svn,真是辛苦fai大了!

我們這邊使用的server為gitlab。

首先我們先在gitLab上創一個空的project,
(當然你也可以在本機創好在push上去,會這樣
做是因為gitlab有提供語法XD)



































git 與 svn最大不同在於
svn是直接commit到server端,
並且本機不會有其他版本的資訊,

git則是每次commit都是先到自己的本機,
再用push送到server,所以本機會有自己完整
的版本資訊,

其實我還是喜歡用svn的,
自己以前還直接在研究室的電腦架svn server XD,

進入正題:

設定個人資訊:
可以用以下指令查看,
git config --list

user.name=lewisli
user.email=lewisli.acer@gmail.com
又或者是到 .gitconfig中察看,

設定個人資訊
git config --global user.name "lewisli"
git config --global user.email "lewisli.acer@gmail.com"

當然也可以針對此目錄設定local的個人資訊。
http://lewisli1.blogspot.tw/2015/03/git-specify-multiple-users-user-local.html
接著輸入以下指令
用來建立此目錄的git設定檔與gitlab的連結,
mkdir gitTutorial
cd gitTutorial
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin http://XXX.xxx.xxx.xxx:7070/lewisli/gitTutorial.git
git push -u origin master

-m的意思是說 要加入message(版本控管 log很重要阿)
其他可用 git commit -h 自己看


































如此成功上傳了
可用
git log --stat
git log -p 
來查看commit資訊


clone git server上面的專案
git clone http://XXX.xxx.xxx.xxx:7070/lewisli/gitTutorial.git

通常一個project會有一些不需commit的檔案,
所以可以在.gitignore做設定,
git會去讀這個檔案來知道哪些檔案不需要上傳,
參考
http://lewisli1.blogspot.tw/2015/03/git-gitingore-white-list.html


===================================================

注意1:clone與github上的fork是不同的
詳見:
http://luckyyang.github.io/blog/2013/03/23/fork-you-github/
http://site.douban.com/196781/widget/notes/12161495/note/269163206/

注意2:clone,pull , fecth 是不同的
詳見:
http://blog.mikepearce.net/2010/05/18/the-difference-between-git-pull-git-fetch-and-git-clone-and-git-rebase/

2015年3月26日 星期四

[git] .gitingore , white list | ignore every except XXX & XXX



*
#ignore all

!src/
#file under the src/ won't be ignored

!.build.properties
#build.properties won't be ignored

2015年3月25日 星期三

[git] specify multiple users | 指定不同的user (local & global)

因為小弟之前只有再用githib,
當初安裝時他就幫我設定好user的相關資訊,
而且是global的


git config --global user.name "Your Name Here"
git config --global user.email your@email.com

但現在團隊要用gitlab來控管專案
我總不能用我github的身分來做動作吧.

所以隊要開發的專案設一個user

git config user.name "Your Name Here"
git config user.email your@email.com