File: git-force-clone.md

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (56 lines) | stat: -rw-r--r-- 1,641 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
git-force-clone(1) -- overwrite local repositories with clone
===

## SYNOPSIS

`force-clone --help`  
`force-clone {remote_url} {destination_path}`  
`force-clone --branch {branch_name} {remote_url} {destination_path}`  

## DESCRIPTION

Provides the basic functionality of `git clone`, but if the destination git
repository already exists it will force-reset it to resemble a clone of the
remote.

Because it doesn't actually delete the directory, it is usually significantly
faster than the alternative of deleting the directory and cloning the
repository from scratch.

**CAUTION**: If the repository exists, this will destroy *all* local work:
changed files will be reset, local branches and other remotes will be removed.

## PROCESS

If `target-directory` doesn't exist or isn't a git repository then the
arguments will simply be passed through to `git clone`.

If `target-directory` exists and is a git repository then this will:

- Remove all remotes
- Set the origin remote to `{remote_url}` and fetch the remote
- Discover the default branch, if no branch was specified
- Check out the selected branch
- Delete all other local branches

## OPTIONS

`{remote_url}` - The URL for a git remote repository of which to make a clone.
`{destination_path}` - A path to the local git repository location to clone into.
`--branch {branch_name}` - After cloning, checkout this branch.

## EXAMPLES

`git-force-clone -b master git@github.com:me/repo.git ./repo_dir`

## AUTHOR

Written by Robin Winslow <robin@robinwinslow.co.uk>.

## REPORTING BUGS

<https://github.com/tj/git-extras/issues>

## SEE ALSO

<https://github.com/tj/git-extras>