GitHub使用方法
git下載地址:https://git-scm.com/downloads 下一步下一步就好了
在cmd輸入 git --version
在桌面空白右鍵 Git Bash Here命令行
輸入 git --version
在https://github.com/注冊一個賬號??
?
?配置sshkey
cd ~/.ssh
ll 查看下所有的目錄
進入命令? cd /
ssh-keygen -t rsa -C "1341376695@qq.com"一直回車,不用管
ll
下面多了2個文件
pwd
cat id_rsa.pub
查看復制
?title隨便起個什么名字就好
2.配置多個sshkey
cd ~/.ssh
vim config 沒有的話,vim就創建了一個
Host github.com
HostName github.com
User? 這個就是user填寫的地址
?
?IdentityFile 填寫的是id_rsa的絕對路徑
3.在gitup創建項目
?
??打開命令行
mkdir muke
cd muke
git clone?git@github.com:xuzhongtao/test1.git 倉庫克隆到本地
cd AutoTest 進入倉庫
vim test.txt
輸入一些內容
cat test.txt
git status 查看本地倉庫文件狀態
git add test.txt報錯
解決辦法:
$ rm -rf .git // 刪除.git $ git config --global core.autocrlf false //禁用自動轉換然后重新執行:
$ git init $ git add 文件名it中報unable to auto-detect email address 錯誤的解決拌辦法
2015年11月25日 15:14:45?一步一臺階?閱讀數:28547 昨天剛配置好的git,今天剛要commit一些修改,就遇到了這個問題** Please tell me who you are.
Run
? git config --global user.email "you@example.com"
? git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'tim@newton.(none)')
后來找到了解決辦法:
找到工程目錄的.git文件夾,打開之后找到config文件,在最后邊加上一句話
[user]
?email=your email
?name=your name
your email 和your name隨便寫上就行 -------------------------------------------------------------------------------------
git status? ?
git commit -m "增加測試文件"? ?增加本次提交文件的說明 回車
git push 推送到gitup網站上?
報錯
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
and then push using the remote name
.或在命令行上創建一個新的存儲庫
git init git add README.md git commit -m“first commit” git remote add origin https://github.com/xuzhongtao/test1.git git push -u origin master...或從命令行推送現有存儲庫
git remote add origin https://github.com/xuzhongtao/test1.git git push -u origin master-------------------------------------------------------------------------
git pull? 拉取
4.項目分支
git branch 查看本地分支
git branch -a 查看遠程端的分支明令? ?多了一行
git checkout? -b branch1? ? ? ? ? ? ? ? ?在本地創建分支
vim test.text 編輯這個文件
保存 退出
git add test.txt
git commit? -m? "提交到分支1的內容"
git push? 提交
git push --set-upstream origin branch1
?5.分支操作--刪除分支
git branch -d branch1 刪除本地分支 不能刪除自已使用得分支
git checkout master? 切換master
git branch -r -d origin/branch1 刪除遠程的分支
git push origin :branch1? ? origin后面有一個空格? 刪除遠程的分支
6.git合并分支
git checkout -b mergedemo? 創建一個分支
git merge mergedemo 合并分支
7.git項目操作
git? ?add . 更新所有的文件?
git reset --hard HEAD^ 回退到上一個版本
git reset --hard HEAD^?回退到上上一個版本
git reset --hard HEAD~100? 回退到上100一個版本
git reflog? 版本的id號
git reset --hard 657a18? 通過id號指定哪個版本
?----------------------------------------------------------------------------------------------
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
解決辦法:
$ git pull origin master
$ git push origin master
--------------------------------------------------------------------------------------------------------------
解決方法
可以通過如下命令進行代碼合并【注:pull=fetch+merge]
git pull --rebase origin master
轉載于:https://www.cnblogs.com/xuzhongtao/p/10092879.html
總結
以上是生活随笔為你收集整理的GitHub使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。