
Git Github應用示例客戶端切換不同用戶使用说明從git全新pull一個新項目修改eclipse 的 tokengithub 生产token事先pullpush后synch创建Project本地初始化查看当前文件夹下的文件管理状态把所有的文件添加到本地仓库管理界面更改Branch把本地文件push到服务器的另一个分支最简单的一次提交$ git status$ git add .$ git commit -m log$ git pushGIT Command安装查看版本查看git安装路径查看、切換目錄查看所有本地分支查看本地和远程跟踪分支檢出並創建projecteclipse import project重命名切換brancher创建branch切换branch創建并切换到brancher删除本地分支合併提交新Brancher合併查看project狀態與remote repository差異贮藏与清理 ([TODO]pop [Stashing and Cleaning]清屏git branch --unset-upstream 刪除跟踪信息git push --set-upstream origin master建立追蹤TrackLocal to Remote修改登錄賬戶Github 客户端Eclipse修改URL修改password從服務器全部替換本地VS studio應用示例客戶端切換不同用戶列出當前用戶$ git credential-manager github list abcboobook退出當前用戶$ git credential-manager github logout abcboobook檢出Coding$ git clonehttps://github.com/wesoftwabdsdcnd.git跳轉到Github的登錄頁進行驗證。#GIT Create Project使用说明從git全新pull一個新項目初始化本地 $ git init 查看本地映射的遠程分支如果之前沒有pull第一次為空 $ git remote -v $ git remote add originhttps://github.com/abc.git $ git pull origin dev修改eclipse 的 tokengithub 生产tokenSettings/Developer Settings/Personal access tokens (classic)事先pullpush后synch因为IDE的git工具只比较最新修改和最后一次pull的版本每次push或者commit前需要解决冲突所以要把服务器上最新版本pull下来本地解决冲突然后再commit。commit后一定要synch或者服务器上的最新版本。为什么一定要synch防止解决本地冲突的时候不是和最新版本进行比较这样即使解决冲突push上去也不是最新版本。synch可以保证本地与服务器同步。即使提交之前pull到最新版本但是在解决冲突的过程中有其他人也会push。所以push之后的synch非常重要。创建Project本地初始化把当前文件夹变成Git仓库成功后多一个git文件夹但是.gitignore是maven的文件。$ git init Initialized empty Git repository inD:/workspace/javaspace/erp/.git/查看当前文件夹下的文件管理状态untrcked files显示所有不受git管理的文件。$ git status On branch master No commits yet Untrackedfiles:(usegit add file...to include in what will be committed).gitignore .mvn/ mvnw mvnw.cmd pom.xml src/ nothing added to commit but untracked files present(usegit addto track)把所有的文件添加到本地仓库$ git add .$ git commit -mthis is frist commit脚本如下echo# openerp README.md git init git add README.md git commit -mfirst commitgit branch -M main git remote add originhttps://github.com/develperofbamboobook/openproject.git git push -u origin main管理界面更改Branch把本地文件push到服务器的另一个分支先切换到提交的目录下 $ git checkout master 如果當前分支與多個主機存在追蹤關係則可以使用-u選項指定一個默認主機這樣後麵就可以不加任何參數使用git push。 $ git push -u origin master最简单的一次提交在本分支下提交$ git status参考下文件状态$ git add .提交所有$ git commit -m ‘log’写备注并提交到本地库$ git push提交到服务器GIT CommandDistributed Version Control System分布式版本控制系统Such as Git、Mercurial、Bazaar、Darcs。镜像客户端并提取最新版本的快照把代码仓库完整地镜像下来。如果服务器发生故障可以通過任何一个镜像出来的本地仓库恢复。安装Download for Windows。从源码进行安装C:\winget install--id Git.Git-e--source winget 已找到 Git[Git.Git]版本2.37.3此应用程序由其所有者授权给你。 ██████████████████████████████47.0MB/47.0MB 已成功验证安装程序哈希 正在启动程序包安装...已成功安装查看版本PS C:\git--version git version2.32.0.windows.2或者 C:\git-v git version2.37.3.windows.1查看git安装路径C:\Windows\system32where git D:\codetool\git\git.exe查看、切換目錄$ cd .. $ pwd查看所有本地分支并输出最后一次提交备注$ git branch -v dev bb059b0 first commit * master bb059b0 first commit查看本地和远程跟踪分支输出显示了存储库中的所有本地和远程跟踪分支名称$gitbranch-amaster*testremotes/origin/master$gitbranchmaster*test$gitbranch-v-vmastercff658a[origin/master]按版本管理*testcff658a[origin/master]按版本管理檢出並創建project默認master branch全部檢出本地切換$gitclone#giturl2.檢出指定branch其它branch在本地被Trackgitclone--branchbranchnameremote-repo-urlorgitclone-bbranchnameremote-repo-url#例如gitclone-bdevhttps://github.com/your/repo.git3.檢出指定branch其它branch不被Trackgitclone--branchbranchname--single-branchremote-repo-urlorgitclone-bbranchname--single-branchremote-repo-urleclipse import project重命名git branch -m 和 git branch -M 是用来移动和重命名分支的。 类似 -c 参数对于参数 -m其只会在目标不存在的时候进行移动和重命名-M 参数则不管目标是否存在都会移动和重命名。 -m -f 可以实现和 -M 相同的效果。git checkout test //把test分支改成newtest git branch -m newtest git branch # * dev # master # newtest切換brancher在project的目錄下切換brancher$cd*rap*d$gitcheckoutdevelopSwitchedtoanewbranchdevelopBranchdevelopsetuptotrackremotebranchdevelopfromorigin或者git switch branch name创建branch$ git branch master切换branch$ git checkout master Switched to branchmaster創建并切换到brancher##在本地創建push時在遠程創建$gitcheckout-btest删除本地分支不能在Branch test 下刪除必須切換到其它目錄如master目錄$gitbranch-dtestDeletedbranchtest(wascff658a).gitbranch-Dbranch_name#強制刪除合併提交新Brancher合併$gitmergedevelop#LocalRepositorygitpush--set-upstreamorigintest查看project狀態與remote repository差異$gitstatus$gitpull#下載服務器端fileor$gitfetchv1.8.4later贮藏与清理 ([TODO]TODO$gitstashpop [Stashing and Cleaning]TODO清屏$cleargit branch --unset-upstream 刪除跟踪信息Git告诉您可以使用删除跟踪信息–unset-upstream。这将清除branch.source.origin和branch.source.merge并停止警告。$gitstatusOnbranchmasterYourbranchisbasedonorigin/master,buttheupstreamisgone.(usegit branch --unset-upstreamtofixup)git push --set-upstream origin master提交並在遠程創建master branch$gitpush--set-upstreamoriginmasterEverythingup-to-dateBranchmastersetuptotrackremotebranchmasterfromorigin.建立追蹤TrackLocal to Remote本地庫與遠程庫的對應關係即遙控器$gitbranch--set-upstream-toorigin/masterBranchtestsetuptotrackremotebranchmasterfromorigin.修改登錄賬戶remote: HTTP Basic: Access denied置空後重新設置Git客戶端的賬號$gitconfig--system--unsetcredential.helperGithub 客户端Focus on what matters instead of fighting with Git. Whether you’re new to Git or a seasoned user, GitHub Desktop simplifies your development workflow.Eclipse修改URL修改password右鍵項目選擇team從服務器全部替換本地VS studioPlease clean your repository working tree before checkout