2015年4月18日 星期六

git - note



Clone from GIT and develop
git clone https://github.com/wahengchang/testgit
git fetch origin

git add .
git commit -m "edited by 2"
git push origin

Pull from remote
git pull origin branch1


To see change on remote
是否 out of data
git remote show origin

最近一次 push 的資料
git show-branch *feature1

add and switch to New Branch

git branch feature1
git checkout feature1

Branch Merge to Master
git checkout master
git merge feature1
git push origin master


Switch branch
git branch
git branch -v
git branch feature1
git checkout feature1


List committed files
git show --name-only
git 

To see change on local unPush commit
git log origin/feature1..HEAD
git diff origin/feature1..HEAD
git diff --name-only


cancel unPush commit (可多次cancel,keep changes)

git reset
or
git reset filename
or
git log origin/feature1..HEAD


Confirm to remove (local刪除, Git上存在)
git rm fileName


Revert push
git revert origin


Undo push , Unpush
git reset --hard HEAD@{1}
git push -f origin

Deploy from local branch->remote branch
git push heroku dev:master




Go back to certain commit from different branch
git cherry-pick cb7dfbcfa988a11f0ba1ea9b37a9ec32ce02a674

Go back to certain commit
git reset cb7dfbcfa988a11f0ba1ea9b37a9ec32ce02a674

Stash all file, and pop
git stash
git stash pop

You have not concluded your merge (MERGE_HEAD exists).
git merge --abort
git reset --merge
git add .
git commit -m ""
git push origin
//conflict 
git add .
git commit -m "merge"
git push origin

Everything up-to-date
git push heroku dev:master


Everything up-to-date - 2
git commit --amend
git push . .. ...


How to GitHub Guide Open Source

.gitignore

# 註解,會被忽略。 # 不要追蹤檔名為 .a 結尾的檔案 *.a # 但是要追蹤 lib.a,即使上方已指定忽略所有的 .a 檔案 !lib.a # 只忽略根目錄下的 TODO 檔案。 不包含子目錄下的 TODO /TODO # 忽略build/目錄下所有檔案 build/ # 忽略doc/notes.txt但不包含doc/server/arch.txt doc/*.txt # ignore all .txt files in the doc/ directory doc/**/*.txt



沒有留言:

張貼留言