git help config;//git help command
git config --global user.name "yanlong wang"
git config --global user.email "[email protected]"
git config --global color.ui true //增加命令列顏色
git init;
git status;
git add readme.txt license.doc;//當前目錄下兩個檔案
git add ../docs/*.txt;//docs目錄下的*.txt檔案
git add ../docs/;//add docs目錄下所有
git add --all;//add all files
git add "*.txt";//add all txt files in the whole project
git commit -m "message"; //commit 生成乙個快照snapshot,並壓入snapshot stack
git commit -am "message";//adds and commits in the same step;
git log;//檢視snapshot stack,至頂向下
git diff (head);//show unstaged differences since last commit
git diff head^;//
git diff head^^;
git diff head~5;//show unstaged differences since last 5th commit
git diff --stage;//view staged differences
git reset head license.txt;//unstage license.txt,head refers to last commit locally.從stage->unstage改變還在
git checkout -- license.txt;//blow away all changes since last commit.unstage狀態下blow away改變不在
git reset --soft head^;//undo last commit,put changes into staging.
git commit --amend -m "new message";//overide the last commit.
git reset --hard head^^;//undo last two(^^) commit and all changes.
git remote add origin 增加遠端repo origin的url address.
git push -u origin master;origin->remote repo branch,master->local repo branch
git pull master;可以省略,預設git pull origin master
git remote add ;//add new 遠端倉庫
git remote rm ;//remove remotes repo branch
git push -u
;//to push to remote repo ;branch usually master
git clone (localfoldername);clone遠端repo到localfoldername省略則為當前目錄
git branch;//show all branches of code
git branch
;//create branch
git checkout
;//change branch
git merge
;//merge branch_name to current timeline branch.每一次mergre都會產生一次新的commit,pull=fetch+merge
git branch -d
;//delete branch
git checkout -b
;//create and checkout to branch_name branch
git commit -a;//merge commit,修改衝突後的提交
git checkout -b shopping_cart;
git push origin shopping_cart;//origin指遠方repo,會建立乙個遠端的shopping_cart branch 並關聯local的shopping_cart branch
git commit -am "add some files";
git push;//因為已經tracking了所以直接push。
git branch;//list all local branches
git branch -r;//list all remote branches
git remote show [remote_name];
git push origin :[branch_name]; //delete remote branch
git branch -d/-d [branch_name];//delete local branch
git remote prun origin;//clean up deleted remote branches.
git push heroku-staging staging:master;//will push and deploy staging on heroku.
git tag;//list all tags which is a reference to a commmit(used mostly for release versioning)
git checkout [tag_name];//checkout to tag_name
git tag -a v0.03 -m "version 0.03";//to add a new tag
git push --tags;//push with tags included
git fetch;
git rebase;
git log --pretty=oneline;
git log --oneline -p;
git log --oneline --stat;
git log --oneline --graph;
git log --until=1.minute.ago;
git log --since=1.hour.ago;
git log --since=1.month.ago --until=2.weeks.ago;
git diff sha1..sha2;//diff between commits
git blame index.html --date short;的修改歷史
git rm --cached *.log;//tell git stop tracking *.log files
.gitignore logs/*.log//stop tracking *.log files
git add .gitignore;
git commit -m "ignore all log files";
git config --global alias.mylog \ "log --pretty=format:'%h %s [%an]' --graph"
git config --global alias.lol \ "log --pretty --decorate --pretty=oneline --abbrev-commit --all"
git mylog/lol;//short for
常用命令 Git 常用命令大全
安裝教程可參照 廖雪峰老師的安裝教程。git config 在git中,使用git config 命令來配置 git 的配置檔案,git配置級別主要有3類 1 倉庫級別 local 本地 git 倉庫級別配置檔案,作用於當前倉庫。優先順序最高 2 使用者級別 global,全域性配置檔案,作用於所有...
git 常用命令
檢視是否存在檔案需要上傳 git status git add git commit m 建立遠端倉庫 git remote add origin 116.255.146.153 ruby cd work daily project.git 更新git fetch 116.255.146.153 r...
git常用命令
詳細 1,git log p 命令來顯示每一次提交與其父節點提交內容之間快照的差異。2,為了檢視載入 staged 而並未提交 not committed 的內容差異,可以使用 git diff stage 命令 在git 1.6之前的版本中,使用 cached 適應情形 在執行git commit...