push: Support --cleanup
This option is not specific to sync, so it seemed it should be in either pull or push as well as sync. Since it does modify the remote, it seems better to have it in push; the modification of the local repo pulls in the direction of pull, but not hard enough. Maybe it would be better to have it in both? Sponsored-by: Luke Shumaker on Patreon
This commit is contained in:
parent
31d21578c3
commit
af6b73a7e6
3 changed files with 29 additions and 31 deletions
|
@ -151,15 +151,15 @@ optParser mode desc = SyncOptions
|
||||||
( long "not-only-annex"
|
( long "not-only-annex"
|
||||||
<> help "operate on git branches as well as annex"
|
<> help "operate on git branches as well as annex"
|
||||||
)
|
)
|
||||||
<*> unlesssync False (switch
|
<*> unlessmode SyncMode False (switch
|
||||||
( long "commit"
|
( long "commit"
|
||||||
<> help "commit changes to git"
|
<> help "commit changes to git"
|
||||||
))
|
))
|
||||||
<*> unlesssync True (switch
|
<*> unlessmode SyncMode True (switch
|
||||||
( long "no-commit"
|
( long "no-commit"
|
||||||
<> help "avoid git commit"
|
<> help "avoid git commit"
|
||||||
))
|
))
|
||||||
<*> unlesssync Nothing (optional (strOption
|
<*> unlessmode SyncMode Nothing (optional (strOption
|
||||||
( long "message" <> short 'm' <> metavar "MSG"
|
( long "message" <> short 'm' <> metavar "MSG"
|
||||||
<> help "commit message"
|
<> help "commit message"
|
||||||
)))
|
)))
|
||||||
|
@ -190,24 +190,22 @@ optParser mode desc = SyncOptions
|
||||||
<> help "transfer contents of annexed files in a given location"
|
<> help "transfer contents of annexed files in a given location"
|
||||||
<> metavar paramPath
|
<> metavar paramPath
|
||||||
))
|
))
|
||||||
<*> unlesssync False (switch
|
<*> unlessmode PullMode False (switch
|
||||||
( long "cleanup"
|
( long "cleanup"
|
||||||
<> help "remove synced/ branches from previous sync"
|
<> help "remove synced/ branches from previous sync"
|
||||||
))
|
))
|
||||||
<*> optional parseAllOption
|
<*> optional parseAllOption
|
||||||
<*> case mode of
|
<*> unlessmode PushMode False (invertableSwitch "resolvemerge" True
|
||||||
PushMode -> pure False
|
( help "do not automatically resolve merge conflicts"
|
||||||
_ -> invertableSwitch "resolvemerge" True
|
))
|
||||||
( help "do not automatically resolve merge conflicts"
|
|
||||||
)
|
|
||||||
<*> case mode of
|
<*> case mode of
|
||||||
PushMode -> pure False
|
PushMode -> pure False
|
||||||
_ -> parseUnrelatedHistoriesOption
|
_ -> parseUnrelatedHistoriesOption
|
||||||
<*> pure mode
|
<*> pure mode
|
||||||
where
|
where
|
||||||
unlesssync v a = case mode of
|
unlessmode m v a
|
||||||
SyncMode -> a
|
| mode /= m = a
|
||||||
_ -> pure v
|
| otherwise = pure v
|
||||||
|
|
||||||
parseUnrelatedHistoriesOption :: Parser Bool
|
parseUnrelatedHistoriesOption :: Parser Bool
|
||||||
parseUnrelatedHistoriesOption =
|
parseUnrelatedHistoriesOption =
|
||||||
|
|
|
@ -22,11 +22,11 @@ not normally update the remote's current branch with changes from the local
|
||||||
repository. (Unless the remote is configured with
|
repository. (Unless the remote is configured with
|
||||||
receive.denyCurrentBranch=updateInstead.)
|
receive.denyCurrentBranch=updateInstead.)
|
||||||
|
|
||||||
To make working with such non-bare remotes easier, this command pushes not only
|
To make working with such non-bare remotes easier, this command pushes not
|
||||||
local `master` to remote `master`, but also to remote `synced/master` (and
|
only local `master` to remote `master`, but also to remote `synced/master`
|
||||||
similar with other branches). When `git-annex pull` (or `git-annex sync`)
|
(and similar with other branches). When `git-annex pull` (or `git-annex
|
||||||
is later run on the remote, it will merge the `synced/` branches that
|
sync`) is later run on the remote, it will merge the `synced/` branches
|
||||||
were pushed to it.
|
that were pushed to it.
|
||||||
|
|
||||||
Some special remotes allow exporting a tree of files to them,
|
Some special remotes allow exporting a tree of files to them,
|
||||||
and this command can be used to push to those remotes as well
|
and this command can be used to push to those remotes as well
|
||||||
|
@ -108,6 +108,20 @@ See [[git-annex-preferred-content]](1).
|
||||||
|
|
||||||
Setting this to "cpus" will run one job per CPU core.
|
Setting this to "cpus" will run one job per CPU core.
|
||||||
|
|
||||||
|
* `--cleanup`
|
||||||
|
|
||||||
|
Removes the local and remote `synced/` branches, which were created
|
||||||
|
and pushed by `git-annex push` or `git-annex sync`. This option
|
||||||
|
prevents all other activities.
|
||||||
|
|
||||||
|
This can come in handy when you've pushed a change to remotes and now
|
||||||
|
want to reset your master branch back before that change. So you
|
||||||
|
run `git reset` and force-push the master branch to remotes, only
|
||||||
|
to find that the next `git annex merge` or `git annex pull` brings the
|
||||||
|
changes back. Why? Because the `synced/master` branch is hanging
|
||||||
|
around and still has the change in it. Cleaning up the `synced/` branches
|
||||||
|
prevents that problem.
|
||||||
|
|
||||||
* Also the [[git-annex-common-options]](1) can be used.
|
* Also the [[git-annex-common-options]](1) can be used.
|
||||||
|
|
||||||
# SEE ALSO
|
# SEE ALSO
|
||||||
|
|
|
@ -61,20 +61,6 @@ content by default. This may change in a future version of git-annex.
|
||||||
When `remote.<name>.annex-sync` is set to false, pushing is disabled for
|
When `remote.<name>.annex-sync` is set to false, pushing is disabled for
|
||||||
that remote, and using `--push` will not enable it.
|
that remote, and using `--push` will not enable it.
|
||||||
|
|
||||||
* `--cleanup`
|
|
||||||
|
|
||||||
Removes the local and remote `synced/` branches, which were created
|
|
||||||
and pushed by `git-annex sync`. This option prevents all other syncing
|
|
||||||
activities.
|
|
||||||
|
|
||||||
This can come in handy when you've synced a change to remotes and now
|
|
||||||
want to reset your master branch back before that change. So you
|
|
||||||
run `git reset` and force-push the master branch to remotes, only
|
|
||||||
to find that the next `git annex merge` or `git annex sync` brings the
|
|
||||||
changes back. Why? Because the `synced/master` branch is hanging
|
|
||||||
around and still has the change in it. Cleaning up the `synced/` branches
|
|
||||||
prevents that problem.
|
|
||||||
|
|
||||||
* Also all options supported by [[git-annex-pull]](1) and
|
* Also all options supported by [[git-annex-pull]](1) and
|
||||||
[[git-annex-push]](1) can be used.
|
[[git-annex-push]](1) can be used.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue