保留本地分支 先拉去远程master代码

要保留你当前分支(B分支)上的编辑内容,并且将远程仓库中 master 分支的最新代码同步到本地,可以按照以下步骤进行操作:

推荐做法:拉取到 master 分支再合并到 B 分支
  1. 查看本地分支B是否有未提交更改
    • 首先确保当前B分支上有无未提交更改.
      git status
  2. 暂存未提交的更改
    • 如果有未提交的更改,可以使用 git stash 命令来暂存这些更改。
      git stash save "备注"
    • 或者简化命令:
      git stash
  3. 切换到master分支
    • 切换到master分支
      git checkout master
  4. 拉去远程master分支的最新代码
    • 确保你的git配置了正确的远程仓库,通常是origin,然后从远程仓库拉去最新的master分支
      git fetch origin master
  5. 切换回B分支
    • 拉取完master分支后,再次切换回你的B分支.
      git checkout B
  6. 合并master分支到B分支
    • 将 master 分支的最新提交合并到 B 分支。
      git merge origin/master
  7. 解决可能的冲突
    • 如果合并后有冲突,需要手动解决这些冲突
      git add.
      git commit -m '备注'
  8. 恢复B分支暂存的更改
    • 使用 git stash apply 或 git stash pop 来恢复暂存的更改。
      git stash apply
    • 或者简化命令
      git stash pop
    • git stash apply 会恢复暂存的内容,并保留暂存的状态,以便多次恢复。git stash pop 则会恢复暂存的内容,并移除暂存条目。
  9. 解决可能的冲突
    • 如果恢复暂存区内容后有冲突,需要手动解决这些冲突.解决冲突后,继续提交合并的结果
      git add.
      git commit -m '备注'
  • 使用这种方法可以保持分支历史更加清晰,避免不必要的合并提交,且可以更容易地追踪变更历史

Git 创建本地分支及合并线上生产分支

Git中,创建一个本地分支,在本地分支做修改,等全部修改完成后再同步到线上主分支。这是 Git 版本控制流程中的一个非常常见和推荐的做法。以下是详细步骤:

1.创建本地分支:

首先,你需要从当前分支(通常是 master 或 main,但也可以是其他分支)创建一个新的本地分支。这样做可以让你在一个隔离的环境中工作,而不会影响到其他分支。

git checkout -b your-new-branch-name

这里的 your-new-branch-name 是你想要创建的本地分支的名称。

2.在本地分支上工作:

现在,你可以在这个新创建的本地分支上进行所有的修改、添加文件、提交更改等操作。

# 添加新文件或修改现有文件  
# ... 进行你的工作 ...  

# 将更改添加到暂存区  
git add .  

# 提交更改  
git commit -m "描述你的更改"

同步到远程仓库(可选,但推荐):

在将更改推送到线上主分支之前,通常建议先将你的本地分支推送到远程仓库,以便进行备份和协作。

# 首先确保你已经设置了远程仓库的上游(如果是第一次推送)  
git push -u origin your-new-branch-name

这里的 origin 是远程仓库的默认名称,your-new-branch-name 是你要推送的本地分支的名称。

合并到线上主分支:

当你确定本地分支上的所有更改都已完成并经过测试后,你可以将这些更改合并到线上主分支上。这通常是通过一个 pull request(在 GitHub、GitLab 等平台上)或 merge request(在 GitLab 上)来完成的,但你也可以直接在命令行中执行合并操作(如果你有足够的权限)。
如果你选择使用命令行,并且你有权限直接推送到主分支,你可以这样做:

# 切换到主分支  
git checkout master  

# 从远程仓库拉取最新的主分支更改(确保你的主分支是最新的)  
git pull origin master  

# 合并你的本地分支到主分支  
git merge your-new-branch-name  

# 将合并后的更改推送到远程仓库的主分支  
git push origin master

注意:在实际操作中,直接推送到主分支(或其他受保护的分支)可能需要特殊的权限或配置。在大多数团队协作环境中,推荐使用 pull request 或 merge request 来合并更改,以便进行代码审查和讨论。

(可选)删除本地和远程分支:

如果你的本地分支已经成功合并到主分支,并且你不再需要它,你可以选择删除它。

# 删除本地分支  
git branch -d your-new-branch-name  

# 删除远程分支(如果你已经推送了它)  
git push origin --delete your-new-branch-name

注意:使用 -d 选项删除分支时,Git 会检查该分支是否已经被合并到当前分支。如果还没有合并,Git 会拒绝删除并提示你。如果你确定要强制删除一个未合并的分支,可以使用 -D 选项代替 -d。但在大多数情况下,建议先合并再删除分支。

Git的基本使用

基本的名词和概念

在 Git 版本控制系统中,有一些基本的名词和概念,它们构成了 Git 工作流程的基础。下面是一些核心概念的简要介绍:

仓库(Repository):存放项目文件和版本信息的地方,可以是本地的也可以是远程的。
工作目录(Working Directory):仓库中的文件被检出到一个目录,这个目录就是工作目录,你可以在这里修改文件。
暂存区(Staging Area):也称为索引,是一个准备下次提交的文件列表,你可以在这里选择哪些更改将被包括在提交中。
提交(Commit):将暂存区的更改永久保存到仓库的版本历史中。
分支(Branch):分支是开发线的起点,你可以创建分支来开发新功能或修复错误,而不会影响主分支。
合并(Merge):将一个分支的更改合并到另一个分支中,通常是将特性分支的更改合并回主分支。
远程仓库(Remote Repository):通常是一个服务器上的仓库,用于多人协作,你可以推送(push)和拉取(pull)更改。
克隆(Clone):从远程仓库复制仓库到本地,包括所有分支和标签。
拉取(Pull):从远程仓库获取最新的更改并合并到你的本地分支。
推送(Push):将你的本地分支的更改发送到远程仓库。
标签(Tag):标记特定的提交,通常用于版本发布。
冲突(Conflict):当两个分支中的相同文件的同一行被修改,合并时 Git 无法自动解决,需要手动解决。
HEAD:指向当前分支的最新提交。
索引(Index):有时与暂存区同义,是准备下一次提交的文件列表。
变基(Rebase):将一系列提交从一个分支上重新应用到另一个分支上,以保持线性的提交历史。

Git常用命令

Git 的命令和操作是 Git 版本控制系统中的核心部分,下面是一些基本的 Git 命令和它们通常的操作步骤:

初始化仓库:

git init

创建一个新的本地 Git 仓库。

检出仓库:

git clone [url]

从一个远程仓库克隆到本地。

查看状态:

git status

查看当前工作目录和暂存区的状态。

添加文件到暂存区:

git add [file]

将文件或更改添加到暂存区,准备下一次提交。

查看差异:

git diff

查看工作目录与暂存区或最后一次提交之间的差异。

提交更改:

git commit -m "commit message"

将暂存区的更改提交到仓库。

查看提交历史:

git log

查看项目的提交历史。

创建分支:

git branch [branch-name]

创建一个新的分支。

切换分支:

git checkout [branch-name]

切换到指定的分支。

合并分支:

git merge [branch-name]

将一个分支的更改合并到当前分支。

拉取远程分支:

git pull

从远程仓库拉取最新更改并自动合并到当前分支。

推送到远程仓库:

git push [remote-name] [branch-name]

将本地分支的更改推送到远程仓库。

查看远程仓库:

git remote -v

查看远程仓库的详细信息。

删除分支:

git branch -d [branch-name]

删除本地分支。

解决冲突:

当合并时出现冲突,Git 会停止合并并让你手动解决。解决后,再次提交。

查看文件更改:

git diff [branch-name]

查看当前分支与另一个分支的差异。

重置更改:

git reset [file]

将文件从暂存区撤销到工作目录。

查看分支图:

git branch --all --graph

以图形方式查看所有分支。

变基分支:

git rebase [branch-name]

将当前分支上的提交重新应用到另一个分支上。

标签管理:

git tag [tag-name]

给当前提交打上标签,通常用于版本发布。

这些命令和操作步骤是 Git 使用中的基础,掌握它们可以帮助你更有效地进行版本控制。

Git 拥有一个庞大的命令集,这些命令覆盖了从基础到高级的多种使用场景。在开始使用 Git 之前,建议您先学习一些基础的版本控制概念。通过不断的实践和探索,您将逐步深入了解 Git 的强大功能。Git 的真正魅力在于它的灵活性和丰富功能,它能够适应各种复杂的开发环境和工作流程。

————————————————

原文链接:https://blog.csdn.net/2301_76884890/article/details/141158307

Git放弃当前编辑区的全部编辑

在 Git 中,若你正在对文件进行编辑且希望放弃所有未提交的更改(即撤销对文件的修改),你可以根据文件的当前状态采取不同的操作。以下是一些常见的方法:

若文件已被添加到暂存区(Staging Area):
如果你已经使用 git add 命令将文件添加到暂存区,但之后决定撤销这些更改,你可以使用 git reset HEAD <文件> 命令。这将从暂存区中移除文件,但文件的更改仍保留在工作目录中。接下来,你可以使用 git checkout — <文件> 或 git restore –source=<文件> –staged –worktree(Git 2.23+ 版本)来完全撤销这些更改。
但更简便的方法是直接使用 git restore –staged –worktree <文件>,该命令会同时撤销暂存区和工作目录中的更改(Git 2.23+)。若你使用的是旧版 Git,则可能需要分别执行 git reset HEAD <文件> 和 git checkout — <文件>。

若文件尚未添加到暂存区:
如果文件更改仍停留在工作目录中,未添加到暂存区,你可以直接使用 git checkout — <文件> 或 git restore –source=<文件> –worktree 来撤销这些更改。
撤销整个工作目录的更改:
如果你想要撤销工作目录中所有文件的更改(即放弃当前编辑区的全部编辑),可以使用 git checkout — . 或 git restore –source=. –worktree(Git 2.23+)。但请注意,这样做会丢失所有未提交的更改,因此请确保你不再需要这些更改。
对于 Git 2.23 及更高版本,推荐使用 git restore 命令,因为它提供了更清晰的选项来区分暂存区和工作目录的更改。

使用储藏(Stash)功能:
如果你想要保留这些更改以便稍后应用,但当前需要撤销它们,可以使用 git stash 命令。这将保存你的更改到一个储藏中,你可以随时使用 git stash pop 或 git stash apply 来重新应用这些更改。
清理工作目录:
在撤销更改后,如果你想要确保工作目录完全干净(即没有任何未跟踪的文件或目录),可以使用 git clean 命令。但请谨慎使用此命令,因为它会删除未跟踪的文件和目录,且通常没有撤销操作。
请记住,在撤销更改之前,最好先使用 git status 命令来查看当前的工作目录和暂存区状态,以确保你了解将要撤销哪些更改。

另外,需要注意的是,git checkout 在 Git 2.23 版本后已被 git switch 和 git restore 命令所部分取代,用于更清晰地管理分支和工作树更改。因此,如果你使用的是较新版本的 Git,建议熟悉并使用这些新命令。但在本回答中,为了兼容性,我仍然提到了 git checkout 命令。

PHP7.4后 ?? 与 ?:的区别

PHP7.4版本发布后,新增空(NULL)合并运算符??的语法糖,如果变量存在且值不为 NULL, 它就会返回自身的值,否则返回它的第二个操作数。与以前就存在的简写的条件运算符?:有点类似;

??与?:对比


a = 1;b = a ?: 2;//a 为true就返回自身,否者返回第二个操作数
c =a ?? 2;//a不为null就返回自身,否者返回第二个操作数
// dd(b,c);// int(1)  int(1)a = 0;
b =a ?: 2;//a 为true就返回自身,否者返回第二个操作数c = a ?? 2;//a不为null就返回自身,否者返回第二个操作数
// dd(b,c);// int(2)  int(0)

a = null;b = a ?: 2;//a 为true就返回自身,否者返回第二个操作数
c =a ?? 2;//a不为null就返回自身,否者返回第二个操作数
dd(b,$c);// int(2)  int(2)

空合并运算赋值符 ??=

$name = $name ?? 'john'
可以简写成
$name ??= 'john'

VSCode 汉化

步骤 1:安装中文语言包

打开 VSCode,按 Ctrl + Shift + P 打开命令面板。
输入 ext install chinese 并按回车键安装中文语言包。

步骤 2:启用汉化

在命令面板中输入 configure display language。
在下拉列表中,选择 Simplified Chinese(简体中文)或 Traditional Chinese(繁体中文)。
步骤 3:重启 VSCode

单击 重启 按钮以重新启动 VSCode 并应用语言更改。
步骤 4:调整默认语言

在命令面板中输入 settings.json。
添加以下行到 settings.json 文件末尾:
"locale":"zh-CN"

如果使用繁体中文,则将 “zh-CN” 替换为 “zh-TW”。
步骤 5:完成

重新启动 VSCode,您的界面现在将显示为中文。

Linux查看日志

在Linux系统中,/var/log/auth.log 和 /var/log/secure 是用于记录认证相关信息的日志文件,但它们的存在取决于你使用的Linux发行版及其配置。Debian及其衍生版(如Ubuntu)通常使用/var/log/auth.log,而Red Hat及其衍生版(如CentOS、Fedora)则倾向于使用/var/log/secure。

检查日志文件
要检查这些日志文件,你可以使用cat、less、tail、grep等命令。以下是一些常用的方法来查看这些文件的内容:

使用cat命令
bash
cat /var/log/auth.log # 对于Debian/Ubuntu系统
cat /var/log/secure # 对于CentOS/RedHat系统
但请注意,如果日志文件非常大,cat命令会一次性输出整个文件的内容,这可能会导致你的终端滚动非常快,难以阅读。

使用less命令
less命令允许你逐页查看文件内容,非常适合查看大文件。

bash
less /var/log/auth.log # 对于Debian/Ubuntu系统
less /var/log/secure # 对于CentOS/RedHat系统
在less命令的界面中,你可以使用方向键来上下滚动,按q键退出。

使用tail命令
如果你只对最近的日志条目感兴趣,可以使用tail命令。默认情况下,tail显示文件的最后10行。

bash
tail /var/log/auth.log # 对于Debian/Ubuntu系统
tail /var/log/secure # 对于CentOS/RedHat系统
你也可以使用-n选项来指定显示的行数,例如tail -n 50 /var/log/auth.log会显示最后50行。

使用grep命令搜索特定内容
如果你正在寻找包含特定文本的行,可以使用grep命令。

bash
grep ‘failed’ /var/log/auth.log # 搜索包含”failed”的行
grep ‘root’ /var/log/secure # 搜索包含”root”的行
注意事项
确保你有足够的权限来读取这些日志文件。通常,你需要以root用户或使用sudo命令来查看它们。
如果你的系统配置或发行版不同,可能需要使用不同的日志文件或路径。
在某些系统上,/var/log/auth.log 和 /var/log/secure 可能不存在,或者可能使用其他日志文件来记录认证信息。如果你找不到这些文件,可以尝试查找/var/log目录下的其他相关日志文件,或者使用journalctl命令(如果你的系统使用systemd)来查看日志。

宝塔安装svn并自动发布

  • 查看是否已经安装了svn

svnserve --version

  • 没有安装的话安装subversion,直接用yum 安装

yum install -y subversion

  • 检测是否安装成功

svn --version

  • 创建svn目录

mkdir /www/server/svn

  • 创建svn配置目录

mkdir /www/svnconfig

分别添加4个文件

  • add.sh
#!/bin/bash

echo -e "\n"

read -t 30 -p "请输入仓库名称:" NAME

echo -e "\n"
#echo "仓库名称为:NAME"

#NAME=oa


PATH="/www/server/svn/NAME"

if [ -d "PATH" ];then
    echo -eNAME"仓库已经存在\n"
    exit 1
fi

/usr/bin/svnadmin create PATH

/bin/cp /www/svnconfig/svnserve.confPATH/conf/

/bin/cp /www/svnconfig/post-commit PATH/hooks/

echo -e "export LANG=zh_CN.UTF-8 \n\n/usr/bin/svn update /www/wwwroot/NAME --username svn --password aseghwiotghoisdhagoih --no-auth-cache \n\nchown -R www:www /www/wwwroot/NAME">>PATH/hooks/post-commit

if [ -f "/www/wwwroot/NAME/.user.ini" ];then
    /usr/bin/chattr -i /www/wwwroot/NAME/.user.ini
fi


echo -e "["NAME":/] \n@itwork=rw \n*=\n\n">>/www/svnconfig/authz

/usr/bin/svn checkout svn://127.0.0.1/NAME /www/wwwroot/NAME --username svn --password aseghwiotghoisdhagoih --no-auth-cache

echo -e "\n"

/bin/chown -R www:www /www/wwwroot/NAME


echo -e "目录创建成功\n"


  • authz
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the 'authenticated' token,
###  - only anonymous users, using the 'anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
itwork = svn,svn2

# [/foo/bar]
# harry = rw
# &joe = r
#*=既是所有人为空权限
# * =

# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r

#[www.baidu.com:/] 
#itwork=rw 
#*=

  • passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
svn = xxxxxxx
svn2 = xxxxxxx
  • post-commit
#!/bin/sh

# POST-COMMIT HOOK
#
# The post-commit hook is invoked after a commit.  Subversion runs
# this hook by invoking a program (script, executable, binary, etc.)
# named 'post-commit' (for which this file is a template) with the 
# following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] REV          (the number of the revision just committed)
#
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares.
#
# Because the commit has already completed and cannot be undone,
# the exit code of the hook program is ignored.  The hook program
# can use the 'svnlook' utility to help it examine the
# newly-committed tree.
#
# On a Unix system, the normal procedure is to have 'post-commit'
# invoke other programs to do the real work, though it may do the
# work itself too.
#
# Note that 'post-commit' must be executable by the user(s) who will
# invoke it (typically the user httpd runs as), and that user must
# have filesystem-level permission to access the repository.
#
# On a Windows system, you should name the hook program
# 'post-commit.bat' or 'post-commit.exe',
# but the basic idea is the same.
# 
# The hook program typically does not inherit the environment of
# its parent process.  For example, a common problem is for the
# PATH environment variable to not be set to its usual value, so
# that subprograms fail to launch unless invoked via absolute path.
# If you're having unexpected problems with a hook program, the
# culprit may be unusual (or missing) environment variables.
# 
# Here is an example hook script, for a Unix /bin/sh interpreter.
# For more examples and pre-written hooks, see those in
# the Subversion repository at
# http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/ and
# http://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/


REPOS="1"
REV="2"

mailer.py commit "REPOS" "REV" /path/to/mailer.conf




##WEB=/www/wwwroot/www.baidu.com 
#WEB=/www/wwwroot/

#export LANG=zh_CN.UTF-8

#/usr/bin/svn update WEB --username svn --password 1111 --no-auth-cache 

#chattr -iWEB/.user.ini

#chown -R www:www $WEB








  • svnserve.conf
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.apache.org/ for more information.

[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete 
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# anon-access = read
# auth-access = write
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
# password-db = passwd
password-db = /www/svnconfig/passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.  Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.  If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
# authz-db = authz
authz-db = /www/svnconfig/authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.  The default realm
### is repository's uuid.
# realm = My First Repository
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

  • 启动SVN

svnserve -d -r /www/server/svn

  • 进入svn配置目录,执行add.sh
    ./add.sh

mysql常用日期、时间查询

select curdate();  --获取当前日期
select last_day(curdate());  --获取本月最后一天。
select DATE_ADD(curdate(),interval -day(curdate())+1 day);  -- 获取本月第一天
select date_add(curdate()-day(curdate())+1,interval 1 month);  -- 获取下个月的第一天
select date_sub(curdate()-day(curdate())+1,interval 1 month);  -- 上个月第一天
select last_day(date_sub(curdate(),interval 1 month)); -- 上个月最后一天
select DATEDIFF(date_add(curdate()-day(curdate())+1,interval 1 month ),DATE_ADD(curdate(),interval -day(curdate())+1 day)) from dual; --获取当前月的天数
select subdate(curdate(),date_format(curdate(),'%w')-1) -- 本周一
SELECT DATE_SUB(now(),INTERVAL WEEKDAY(now()) day); -- 本周一
select subdate(curdate(),date_format(curdate(),'%w')-7) -- 本周日

-- 前一秒
select SUBDATE(now(),interval 1 second);
-- 前一分钟
select SUBDATE(now(),interval 1 minute);
-- 前一个小时
SELECT date_sub(NOW(), interval 1 hour)
-- 前一天某个时间点
SELECT date_sub(DATE_FORMAT(NOW(),'%Y-%m-%d 18:00:00'), interval 1 day)
-- 前一天
SELECT date_sub(now(),interval 1 day)
-- 前一月 后一月
date_sub(curdate(),interval 1 month) 表示 2013-04-20
date_sub(curdate(),interval -1 month) 表示 2013-06-20
-- 前一年 后一年
date_sub(curdate(),interval 1 year) 表示 2012-05-20
date_sub(curdate(),interval -1 year) 表示 2014-05-20
-- 字符串转日期
select str_to_date('2017-11-20', '%Y-%m-%d %H:%i:%s');
-- 时间转字符串
select date_format(now(), '%Y-%m-%d');
-- 字符串转时间戳
select unix_timestamp('2016-01-02');
-- 时间戳转时间
select from_unixtime(1451997924);
-- 时间戳转字符串
select from_unixtime(1451997924,'%Y-%d');
-- 时间转时间戳
select unix_timestamp(now());

-- 查询前一天数据
select * from user_info where join_time BETWEEN date_sub(CURDATE(), INTERVAL 1 DAY) AND date_sub(DATE_FORMAT(NOW(), '%Y-%m-%d 23:59:59'),INTERVAL 1 DAY);
-- 上周一
select subdate(  date_add(subdate( date_add(curdate(), interval -1 day),date_format(date_add(curdate(), interval -1 day),'%w')-1), interval -2 day),date_format( date_add(subdate( date_add(curdate(), interval -1 day),date_format(date_add(curdate(), interval -1 day),'%w')-1), interval -2 day),'%w')-1);
-- 上周日
select date_add(subdate(  date_add(subdate( date_add(curdate(), interval -1 day),date_format(date_add(curdate(), interval -1 day),'%w')-1), interval -2 day),date_format( date_add(subdate( date_add(curdate(), interval -1 day),date_format(date_add(curdate(), interval -1 day),'%w')-1), interval -2 day),'%w')-1), interval 6 day);

原文转自
https://www.cnblogs.com/huangxiaoxue/p/8870839.html