Py学习  »  Git

如何在GITHUB上创建新的分支

Mila Bogomolova • 5 年前 • 1542 次点击  

你好,我试图解决我的问题,但没有成功。 我在Github上创建了一个分支,然后在那里提交了一个分支,我删除了一个分支,但是我知道了我的承诺。我试图用我的SHA创建新的分支,但我不能。 我试着做以下事情

git checkout && git branch - b SPP-69 47127ee98d8247d67f0f2baf3ae316444bc1ea9e
# and got reference is not a tree 47127ee98d8247d67f0f2baf3ae316444bc1ea9e

我试着做下一个

git checkout && git branch - b SPP-69 47127ee98d
# and got 47127ee98d is not a commit and a branch SPP-69 could not be created from it.

enter image description here enter image description here 我没有本地重新登录。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/43519
 
1542 次点击  
文章 [ 2 ]  |  最新文章 5 年前
CodeWizard
Reply   •   1 楼
CodeWizard    6 年前

看起来您的计算机上没有本地提交。

# Grab the content from the server
git fetch --all --prune

# Now checkout the desired commit
git checkout -b <branch name> <SHA-1>

如何找出包含某个tee对象的提交?

您需要找到提交本身,然后检查它。

检查日志中的提交,然后 checkout -b <SHA-1> 正如你所做的那样

如果无法通过GITHUB Web找到该脚本,请使用此脚本:

#! /bin/sh

# The tee sha-1 which you are searching for its parent
treeish=<your tree sha-1>

# The name of the branch to search in
branch=<branch names>

# loop over all the commits in the given branch
git rev-list $branch |

    # search the commits 
    while read commit_id; do
        if git ls-tree -d -r --full-tree $sha_id | grep $branch; 
           then echo " -- found at $commit_id"
        fi
    done

` `

VonC
Reply   •   2 楼
VonC    6 年前

我可以创建一个分支,但是我不能使用没有分支的提交

这意味着它不再被任何分支或标记引用,因此在默认情况下不会被获取,即使是由 git fetch --all .

尝试并单击新的拉取请求:它应该创建一个 PR branch that you can then fetch locally .

git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME

替换 BRANCHNAME 以您要创建的分支的名称命名。