私信  •  关注

CodeWizard

CodeWizard 最近创建的主题
CodeWizard 最近回复了
5 年前
回复了 CodeWizard 创建的主题 » 使用-D恢复已删除的git分支
7 年前
回复了 CodeWizard 创建的主题 » 如何使用uu name_uuuu==”uuuu main_uuu“来编写python脚本[副本]

系统(Python解释器)为源文件(模块)提供了许多变量你可以随时得到他们的价值观,所以,让我们关注 __姓名__ 变量/属性:

当Python加载源代码文件时,它将执行其中找到的所有代码(请注意,它不会调用文件中定义的所有方法和函数,但会定义它们。)

在解释器执行源代码文件之前,它为该文件定义了一些特殊变量; __姓名__ 是Python为每个源代码文件自动定义的特殊变量之一。

如果Python将这个源代码文件作为主程序(即您运行的文件)加载,那么它将设置 __姓名__ 变量使此文件具有值 “主要” .

如果这是从另一个模块导入的, __姓名__ 将设置为该模块的名称。

所以,在你的例子中:

if __name__ == "__main__":
   lock = thread.allocate_lock()
   thread.start_new_thread(myfunction, ("Thread #: 1", 2, lock))
   thread.start_new_thread(myfunction, ("Thread #: 2", 2, lock))

表示代码块:

lock = thread.allocate_lock()
thread.start_new_thread(myfunction, ("Thread #: 1", 2, lock))
thread.start_new_thread(myfunction, ("Thread #: 2", 2, lock))

仅当您直接运行模块时才会执行;如果另一个模块正在调用/导入它,则不会执行代码块,因为 __姓名__ 不等于“ 主要的 “在这种情况下。

希望这有帮助。

5 年前
回复了 CodeWizard 创建的主题 » 如何在GITHUB上创建新的分支

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

# 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

` `

5 年前
回复了 CodeWizard 创建的主题 » 我正在使用ij idea。如何避免git pull操作失败?

这和 .gitignore 这意味着当其他人在远程存储库中修改同一文件时,您有未提交的更改。

提交更改,然后执行拉取

# add your files to the staging area
git add . (or any other file that you need)

git commit

# now pull
git pull

或者如果你不想承诺:

git stash 

# now pull
git pull

我没有提交.idea目录中的文件,因为我想将其推送到远程分支,并且禁止将这些文件推送到远程分支。

  • 如果您没有将它们添加到gitignore中,请添加它们
  • 如果已经提交,请将其从索引中删除

    # remve the commited files
    git rm --cached <file list>
    

或者如果你想把它们从历史中完全删除

BFG - https://rtyley.github.io/bfg-repo-cleaner/

enter image description here

从现在起使用此忽略文件:

https://www.gitignore.io/api/intellij


5 年前
回复了 CodeWizard 创建的主题 » 带有参数和鱼壳的git别名

没有 git current-branch .

如果需要当前分支名称:

# extract the current branch name
git branch | grep \* | cut -d ' ' -f2

# or 
git rev-parse --abbrev-ref HEAD

# since you are already on the current branch all you need is pull & merge
# be aware that there can be conflicts
into = "!f() { git pull; git merge $B --no-edit; }; f"

如果要传递参数并签出不同的分支,则别名中已包含该分支

git checkout $1