Github入門與實踐css
3.0.8普通用戶版account.json跳過登錄註冊方法已失效,請安裝企業版
官網:https://www.sourcetreeapp.com...html
進入 sourcetree 目錄, 在資源管理器中進入如下地址node
%LocalAppData%\Atlassian\SourceTree\
放入如下文件 accounts.json
git
[ { "$id": "1", "$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity", "Authenticate": true, "HostInstance": { "$id": "2", "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountInstance, SourceTree.Host.AtlassianAccount", "Host": { "$id": "3", "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountHost, SourceTree.Host.AtlassianAccount", "Id": "atlassian account" }, "BaseUrl": "https://id.atlassian.com/" }, "Credentials": { "$id": "4", "$type": "SourceTree.Model.BasicAuthCredentials, SourceTree.Api.Account", "Username": "", "Email": null }, "IsDefault": false } ]
ssh-keygen -t rsa -C "email@email.com" // 一路回車結束
~/.ssh/id_rsa.pub
,能夠用 cat ~/.ssh/id_rsa.pub
查看Header部分只有一行,包括三個字段:type(必需)、scope(可選)和subject(必需)。 type:es6
如下以d3-foo
插件發佈爲例github
If you’re ready to share your code with the world, make your first commit:docker
git add . git commit
Then create a new repository on GitHub. Add the git remote, and push:npm
git remote add origin git@github.com:{USERNAME}/d3-foo.git git push -u origin master
Replace {USERNAME}
with your GitHub user name and d3-foo with your plugin name, obvs.json
Next, create a git tag that corresponds to the version in your package.json file. (If this is not your first release, you’ll also want to bump the version to 0.0.2, 0.1.0, or 1.0.0 as appropriate.) You can push commits as frequently as you like, but periodically you should bundle these commits together into a release. Tags are simply a mechanism for identifying releases in the repository.segmentfault
git tag -a v0.0.1
(Alternatively, use npm version, which also edits the package.json file for you.)
Push the tag to GitHub:
git push --tags
npm publish
As a side-effect of publishing, NPM will create a d3-foo.zip archive of your release in the build folder. Add this as a custom download to your GitHub releases (for example, see d3-shape) so that people can download your code without needing to use NPM.
Edit your release notes to tell people what’s changed!
Once you’ve published the first time, add your plugin to the wiki. If you want collaborators, let me know, and you can transfer your repository to the D3 organization and setup a team. You’ll retain admin rights and be able to publish new releases as often as you like!
https://jingyan.baidu.com/art...
倉庫初始化
git init
查看倉庫狀態
git status
添加監控跟新文件
git add -A
提交
git commit -m
推送到遠程倉庫
git push
http://stackoverflow.com/ques...
http://stackoverflow.com/ques...
github中git push origin master出錯:error: failed to push some refs to
.DS_Store .sizecache.json /bower_components /dist /node_modules npm-debug.log yarn-error.log
git checkout -b develop //這時候在本地git倉庫就建了一個develop分支,git status 會發如今develop分支下 //這時候咱們能夠繼續編碼 //當要push上遠程的分支時候須要注意的是,遠程尚未develop分支 因此咱們能夠 git push origin develop git add . git commit -m "「 git push --set-upstream origin develop
這時候在遠程也會發現多了一個develop分支
總結一下 Git 不一樣狀況下如何回滾
在命令行使用git:
在工做區目錄下輸入 git reflog
能夠查詢出每一個歷史版本的commit,每一個commit都有對應的ID,
確認好要退回的ID後輸入:
git reset --hard 確認的ID
即可退回相應的歷史版本
http://chenjsh.cn/demo/demoge...
https://www.atlassian.com/git...
場景是這樣的,在一次提交 PR 的 review 過程當中,我提交的一個文件,在若干 commits 的修改下,最終和最初狀態徹底相同,可是 PR 中卻保留了對該文件的提交歷史,所以 reviewer 但願我能夠將這個文件移除提交歷史。
這個主要須要用到 git rebase ,步驟以下:
git log filename
: 首先經過 git log 來查詢要回滾到的 commit idgit reset commit-id filename
: 對該文件進行 reset 操做(撤銷提交歷史相關的修改)git checkout filename
: 對其進行 checkout 操做(撤銷對文件自己的修改)git commit --amend
: 修改提交歷史信息git rebase --continue/git push
: 同步待代碼測試沒問題,再將本身分支的內容合併到master 分支,而後提交到遠程服務
git checkout master git merge <branchname> git push origin master
git支持使用易記的字符串和附加信息爲特定的快照打標籤。你能夠利用標籤爲開發樹
(development tree)加上信息(例如Mergedin new memory management),使其更爲清晰,或是標
記出分支上特定的快照。例如,用標籤標出release-1分支上的release-1.0和release-1.1。
git支持輕量標籤(僅爲快照打標籤)以及註解標籤。
git標籤僅在本地範圍內有效。 git push 默認不會推送標籤。要想把標籤發送到origin倉庫,
必須加上選項 --tags :
$ git push origin --tags
git tag 命令包括能夠用於添加、刪除和列出標籤的選項。
不使用選項的 git tag 命令能夠列出可見標籤:
$ git tag release-1.0 release-1.0beta release-1.1
你能夠經過添加標籤名在當前檢出中建立標籤:
$ git tag ReleaseCandidate-1
在 gittag 命令中加入指定提交的SHA-1,就能夠爲該提交添加標籤:
$ git log --pretty=oneline bef4a35a67c6228cbeb05913302f96966ff33d01 fix 5bc4812c60222956e5157cc8c9a5f06156a7750b change config 4a8bae2f78c412065c8422821feaa4cc5a94c82b change to es6 36fa4f97a31be4bc410eb0b4e940c753485f1c90 fix: mongo docker 85aa77f7e4c03a3512f75c47f7568aef9f8a757f fix :...skipping... bef4a35a67c6228cbeb05913302f96966ff33d01 fix 5bc4812c60222956e5157cc8c9a5f06156a7750b change config 4a8bae2f78c412065c8422821feaa4cc5a94c82b change to es6 36fa4f97a31be4bc410eb0b4e940c753485f1c90 fix: mongo docker 85aa77f7e4c03a3512f75c47f7568aef9f8a757f fix a3e6f734ad19d33889d2298111cde828147b4c01 node:10 => node:10:...skipping... bef4a35a67c6228cbeb05913302f96966ff33d01 fix 5bc4812c60222956e5157cc8c9a5f06156a7750b change config 4a8bae2f78c412065c8422821feaa4cc5a94c82b change to es6 36fa4f97a31be4bc410eb0b4e940c753485f1c90 fix: mongo docker 85aa77f7e4c03a3512f75c47f7568aef9f8a757f fix a3e6f734ad19d33889d2298111cde828147b4c01 node:10 => node:10.15.3-alpine 200e8e81fb285e8ef035cf51236ad5bedaac8393 feats: add dockerf:...skipping... bef4a35a67c6228cbeb05913302f96966ff33d01 fix 5bc4812c60222956e5157cc8c9a5f06156a7750b change config 4a8bae2f78c412065c8422821feaa4cc5a94c82b change to es6 36fa4f97a31be4bc410eb0b4e940c753485f1c90 fix: mongo docker 85aa77f7e4c03a3512f75c47f7568aef9f8a757f fix a3e6f734ad19d33889d2298111cde828147b4c01 node:10 => node:10.15.3-alpine 200e8e81fb285e8ef035cf51236ad5bedaac8393 feats: add dockerfile :...skipping... bef4a35a67c6228cbeb05913302f96966ff33d01 fix 5bc4812c60222956e5157cc8c9a5f06156a7750b change config 4a8bae2f78c412065c8422821feaa4cc5a94c82b change to es6 36fa4f97a31be4bc410eb0b4e940c753485f1c90 fix: mongo docker 85aa77f7e4c03a3512f75c47f7568aef9f8a757f fix a3e6f734ad19d33889d2298111cde828147b4c01 node:10 => node:10.15.3-alpine 200e8e81fb285e8ef035cf51236ad5bedaac8393 feats: add dockerfile 2913f6ec026931ab2b189da91f10e0a43d1fee5e 添加readme dcded2b55f7fd190a1cc8aee2aa5e6b1e50886bd jx_todo_app firstversion
# $ git tag menuComplete ad606b git tag v1.0.1 bef4a35a67
選項 -a 能夠爲標籤加入註解:
$ git tag -a tagWithExplanation
你能夠在命令行中使用 -m 選項定義信息:
$ git tag -a tagWithShortMessage -m "A short description"
若是使用 git show 命令,會顯示以下信息:
$ git show tagWithShortMessage tag tagWithShortmessage Tagger: Clif Flynt <clif@cflynt.com> Date: Fri Dec 23 09:58:19 2016 -0500 6 A short description ...
選項 -d 能夠刪除標籤:
$ git tag tag1 tag2 tag3 $ git tag -d tag2 $ git tag tag2 tag3F
git branch -D `git branch`| grep -E 'fix-*'
git stash
(git儲藏)可用於如下情形:
git stash
會把全部未提交的修改(包括暫存的和非暫存的)都保存起來,用於後續恢復當前工做目錄。
好比下面的中間狀態,經過git stash
命令推送一個新的儲藏,當前的工做目錄就乾淨了。
$ git status On branch master Changes to be committed: new file: style.css Changes not staged for commit: modified: index.html $ git stash Saved working directory and index state WIP on master: 5002d47 our new homepage HEAD is now at 5002d47 our new homepage $ git status On branch master nothing to commit, working tree clean
須要說明一點,stash是本地的,不會經過git push命令上傳到git server上。
實際應用中推薦給每一個stash加一個message,用於記錄版本,使用git stash save取代git stash命令。示例以下:
$ git stash save "test-cmd-stash" Saved working directory and index state On autoswitch: test-cmd-stash HEAD 如今位於 296e8d4 remove unnecessary postion reset in onResume function $ git stash list stash@{0}: On autoswitch: test-cmd-stash
能夠經過git stash pop
命令恢復以前緩存的工做目錄,輸出以下:
$ git status On branch master nothing to commit, working tree clean $ git stash pop On branch master Changes to be committed: new file: style.css Changes not staged for commit: modified: index.html Dropped refs/stash@{0} (32b3aa1d185dfe6d57b3c3cc3b32cbf3e380cc6a)
這個指令將緩存堆棧中的第一個stash刪除,並將對應修改應用到當前的工做目錄下。
你也可使用git stash apply命令,將緩存堆棧中的stash屢次應用到工做目錄中,但並不刪除stash拷貝。命令輸出以下:
$ git stash apply On branch master Changes to be committed: new file: style.css Changes not staged for commit: modified: index.html
可使用git stash list命令,一個典型的輸出以下:
$ git stash list stash@{0}: WIP on master: 049d078 added the index file stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log
在使用git stash apply命令時能夠經過名字指定使用哪一個stash,默認使用最近的stash(即stash@{0})
可使用git stash drop命令,後面能夠跟着stash名字。下面是一個示例:
$ git stash list stash@{0}: WIP on master: 049d078 added the index file stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log $ git stash drop stash@{0} Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
或者使用git stash clear命令,刪除全部緩存的stash。
git 教程
Githug 通關攻略
沉浸式學 Git
git建立本地分支以及推送本地分之至遠程分支
https://segmentfault.com/a/11...
git commit 規範指南
git 技巧
git-stash用法小結