我开始在我的主分支上工作,认为我的任务很简单.过了一会儿,我意识到这将需要更多的工作,我想在一个新的分支中完成所有这些工作.如何创建一个新分支并随身携带所有这些更改而不会弄脏主人?
我不知道为什么我无法检查我之前工作过的分支机构.请参阅以下命令(注意:co是别名checkout):
ramon@ramon-desktop:~/source/unstilted$ git branch -a
* develop
feature/datts_right
feature/user_controlled_menu
feature/user_controlled_site_layouts
master
remotes/origin/HEAD -> origin/master
remotes/origin/develop
remotes/origin/feature/datts_right
remotes/origin/master
ramon@ramon-desktop:~/source/unstilted$ git co feature/user_controlled_site_layouts
error: pathspec 'feature/user_controlled_site_layouts' did not match any file(s) known to git.
Run Code Online (Sandbox Code Playgroud)
我不确定这意味着什么,我似乎无法在Google上找到任何我能理解的内容.
如何查看该分支,以及我可以采取哪些措施来解决这个问题?
更新:
我找到了这个帖子,跑步git show-ref给了我:
97e2cb33914e763ff92bbe38531d3fd02408da46 refs/heads/develop
c438c439c66da3f2356d2449505c073549b221c1 refs/heads/feature/datts_right
11a90dae8897ceed318700b9af3019f4b4dceb1e refs/heads/feature/user_controlled_menu
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/heads/master
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/remotes/origin/HEAD
e7c17eb40610505eea4e6687e4572191216ad4c6 refs/remotes/origin/develop
c438c439c66da3f2356d2449505c073549b221c1 refs/remotes/origin/feature/datts_right
c889b37a5ee690986935c9c74b71999e2cf3c6d7 refs/remotes/origin/master
23768aa5425cbf29d10ff24274adad42d90d15cc refs/stash
e572cf91e95da03f04a5e51820f58a7306ce01de refs/tags/menu_shows_published_only
429ebaa895d9d41d835a34da72676caa75902e3d refs/tags/slow_dev
Run Code Online (Sandbox Code Playgroud)
.git目录上的UPDATE(user_controlled_site_layouts在refs/heads/feature folder)中:
$ ls …Run Code Online (Sandbox Code Playgroud) 这是不可能在服务器上的repo中创建somme子子文件夹?
如果我做:
git push origin dev/master
Run Code Online (Sandbox Code Playgroud)
一切工作找到
但如果我这样做
git push origin dev/sub/master
Run Code Online (Sandbox Code Playgroud)
我懂了:
error: 'refs/heads/dev/sub' exists; cannot create 'refs/heads/dev/sub/master'
Run Code Online (Sandbox Code Playgroud)
我用"git branch -r"检查并直接用ssh检查,没有创建dev/sub文件夹.
怎么了?
我有一个项目是现有FOSS产品的定制.它达到了我们维持长期分叉而不是应用新插件等的程度.我想对维护这个项目的最佳工作流程提出一些建议.
只需在github上分叉项目.超级凌乱维持并让人们加快速度.失败3,4.
创建一个新的存储库,让项目维护者根据需要提取上游代码库的标记版本.例如,git fetch upstream; git merge upstream/sometag tagintegrationbranch不确定如何在此模型中轻松推送上游修复程序.有点失败1.
分叉上游项目,将其用作选项2中的上游项目.用作PR系统的助手.可能需要做一些樱桃选择或一些类似的微观管理来推动代码备份这个工作流程,具体取决于功能/错误分支的管理程度,但应该相当干净.似乎满足大多数标准.
我没考虑过的东西?
git 1.8的另一个问题:
$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to 'gitosis@xxx.xx:xxx.git'
Run Code Online (Sandbox Code Playgroud)
建议?它在升级到1.8之前正在工作.
$ git remote -v
origin gitosis@xxx.xx:xxx.git (fetch)
origin gitosis@xxx.xx:xxx.git (push)
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后我首先尝试了这个:
$ git push origin :refs/heads/refs/heads/master
remote: warning: Allowing deletion of corrupt ref.
To gitosis@xxx.xx:xxx.git
- [deleted] refs/heads/master
Run Code Online (Sandbox Code Playgroud)
不知道那是什么,为什么它是腐败的.
$ git pull
Already up-to-date.
$ git push
error: dst ref refs/heads/master receives from more than one src.
error: failed to push some refs to 'gitosis@xxx.xx:xxx.git'
Run Code Online (Sandbox Code Playgroud)
仍然没有工作,但 …
这是一个常见的用例,我克隆一个存储库,签出一个分支,做一些代码更改,进行多次提交,然后当它稳定时,我做一个推送到远程,最终分支被合并和删除.我离开了一个上游的当地分支机构.
我一直在寻找一种删除所有这些分支的安全方法.从描述来看,似乎git remote prune起源正是这样做的.但它似乎并不适合我.
看到以下行为,分支encrdb_init已被删除remote但git remote prune origin命令似乎没有修剪它.我不知道为什么.
$ git branch
bugfix/encrdb_init
* master
$
$ git remote prune origin
$
$ git checkout bugfix/encrdb_init
Switched to branch 'bugfix/encrdb_init'
Your branch is based on 'origin/bugfix/encrdb_init', but the upstream
is gone.
(use "git branch --unset-upstream" to fixup)
$
$ git branch
bugfix/encrdb_init <<< shouldn't this have been pruned?
* master
Run Code Online (Sandbox Code Playgroud)
供参考添加输出 git remote show origin
$ git remote show origin
* remote origin
Fetch URL: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的Ubuntu guest上的当前分支上创建一个分支.不幸的是我一直收到这个错误:
git checkout -b origin/feature/IF-53-change-validation-window/Tommaso
fatal: cannot lock ref 'refs/heads/origin/feature/IF-53-change-validation-window/Tommaso':
'refs/heads/origin/branch' exists;
cannot create 'refs/heads/origin/branch/Tommaso'
Run Code Online (Sandbox Code Playgroud)
我尝试git gc --prune=now了这里建议链接,但不断得到相同的错误.
在我的工作地点,我们在创建git分支时使用2字母编码命名约定.例如,功能Apple可能是ftr_ap_hotfix,功能橙色可能在分支ftr_or_hotfix中完成.
我想在Jenkins中创建两个单独的工作.一个作业应该编译与名称匹配的所有分支,**_ap_** 另一个作业应该编译与名称匹配的所有分支**_or_**
但是,当我设置它时,Jenkins正在编译所有分支,无论其名称如何.
我究竟做错了什么?有一个更好的方法吗?
我从Jenkins页面获得的唯一帮助如下:
如果要跟踪存储库中的特定分支,请指定分支.如果留空,将检查所有分支的变化并构建.语法格式为:REPOSITORYNAME/BRANCH.此外,BRANCH被识别为*/BRANCH的简写,
'*'被识别为通配符,并被'**'识别为包含分隔符'/'的通配符.因此,origin/branches*匹配origin/branches-foo但不匹配origin/branches/foo,同时origin/branches**匹配origin/branches-foo和origin/branches/foo.
我使用带斜杠的分支有一段时间了,但突然发现在某些情况下无法创建它们
$ git init
Initialized empty Git repository in /home/dimskraft/tests/git-slash-branch/.git/
$ git checkout -b my-branch
Switched to a new branch 'my-branch'
$ git status
On branch my-branch
No commits yet
nothing to commit (create/copy files and use "git add" to track)
$ git checkout -b my-branch/sub-branch
Switched to a new branch 'my-branch/sub-branch'
$ touch myfile.txt
$ git add myfile.txt
$ git commit -m "added myfile.txt"
[my-branch/sub-branch (root-commit) 9be5cc5] added myfile.txt
...
$ git checkout -b my-branch/sub-branch/aaa
fatal: cannot lock ref …Run Code Online (Sandbox Code Playgroud) 我曾经在我的私人git服务器上创建一个repo
git init --bare
Initialized empty Git repository in /home/poc/git_repo/local_display_multi_langs .git/
Run Code Online (Sandbox Code Playgroud)
然后我试着add remote在我的mac上工作.
git remote add origin ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git
Run Code Online (Sandbox Code Playgroud)
执行以下命令
514 git flow init
519 git flow feature start read_xml
524 git ci -am "first ci"
Run Code Online (Sandbox Code Playgroud)
然后尝试将所有分支推送到我的私有git服务器的repo并获得如下例外
[src] $ git push origin feature
poc@172.19.16.101's password:
error: src refspec feature does not match any.
error: failed to push some refs to 'ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git'
Run Code Online (Sandbox Code Playgroud)
我错过或误用了一些步骤吗?
如何将我的工作副本上的所有分支推送到远程服务器?
然后当我从我的git服务器克隆项目时.
如何获得新的克隆项目和原始项目是完全相同的.
感谢@VonC
现在,我可以将本地工作副本上的所有分支推送到远程服务器
git push origin --all
但是当我ssh://poc@172.19.16.101/home/poc/git_repo/local_display_multi_langs.git
在另一个文件夹下执行git clone时.
[local_display_multi_langs] $ git …Run Code Online (Sandbox Code Playgroud) git ×10
git-branch ×3
git-flow ×2
github ×2
git-checkout ×1
git-fork ×1
git-remote ×1
jenkins ×1