There are few things going on within Git that can catch folks unawares. 
The first is that you should compare the idea of whether you want to create 
a duplicate copy, or whether you are looking to create a twin, with a 
separate life of it's own. The latter (for which clone is 'designed') is 
the case when you are building upon the work of others, while the former is 
the 'backup' case. You could look at using the --mirror options for keeping 
duplicates.

Given the 'normal' case is the independent clones case it than become 
necessary to actively tell your local clone exactly which of the other 
clones of the project that you are following (for the 'pull' and 'fetch' 
cases). This is where the tracking information for the 'upstream' comes in. 
While 'pull' was historically the leading use case, it is now best practice 
(usually after a few face plants) to think through the processes you 
want/need and utilise those instead (i.e. split the pull so that you have a 
separate 'fetch' and then a personally chosen alternate to the 'merge' 
step).

A really big learning step, I found, was to realise that 'remote tracking 
branches' are actually local, and are just regular branches (which Git 
tries to keep 'read only'), with easy access and naming. So you can easily 
start a new branch on top of say 'origin/main' (using the common names for 
the remote, and its leading branch). You don't actually need to have a 
personal branch called 'main' that's a duplicate of the 'upstream' 
repository.

It then becomes easy to push your updates back to any 'fork' (clone) that *you 
*have on one of the Gitxxx services. The key is the use of the 
"pushDefault" config setting so that where you 'publish' your updates is 
distinct from the upstream that you follw (which usually won't accept your 
pushes in an open source environment - that's for pull requests;-)
```
[remote]
    pushDefault = my
```

Hope that is useful in getting to grips with the power of Git.
On Friday, August 19, 2022 at 12:07:22 AM UTC+1 MJ Hennebry wrote:

> I have a git repository I use for all related work.
> I cloned it for two reasons:
> A backup.
> Allow testing whether everything needed is under version control.
>
> This seems like something that should be easy.
> If I cannot do it, I might have to give up on version control,
> as git seems to have conquered the world.
>
> To be clear, by "cloned", I mean that I made it with git clone.
> I want to maintain the clone as a more or less exact copy of its mother.
> The clone, of course, would remember its mother.
>
> From git help fetch and git help pull , I gathered I could do this.
> Nyet.
> No combination of git fetch and git pull seems to do the trick.
> Eventually I got
> [hennebry@fedora sqrt-g]$ git pull
> \There is no tracking information for the current branch.
> Please specify which branch you want to merge with.
> See git-pull(1) for details.
>
>     git pull <remote> <branch>
>
> If you wish to set tracking information for this branch you can do so with:
>
>     git branch --set-upstream-to=origin/<branch> master
>
> [hennebry@fedora sqrt-g]$ gvim /tmp/git.txt
> [hennebry@fedora sqrt-g]$ pwd
> /home/hennebry/sqrt-g
> [hennebry@fedora sqrt-g]$ git branch
>   corrections
> * master
>   split1
> [hennebry@fedora sqrt-g]$ 
>
> I am not happy.
> What happened?
> How do I do what I want to do?
> Will I have to process each branch one at a time?
> That could be difficult, since at the moment,
> I cannot even process one branch.
> git fetch --all ?
>
> The mother is on an SD card that through USB has
> been continuously connected to my PC at all times.
> The clone is on my hard drive.
>
> [hennebry@fedora sqrt-g]$ git remote -v
> origin    /run/media/hennebry/data2/mathprog/sqrt-g (fetch)
> origin    /run/media/hennebry/data2/mathprog/sqrt-g (push)
> [hennebry@fedora sqrt-g]$ [hennebry@fedora sqrt-g]$ git diff
> [hennebry@fedora sqrt-g]$ git merge
> fatal: No remote for the current branch.
> [hennebry@fedora sqrt-g]$ 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/2e4d940f-aa13-4ad7-92dd-8c23f0be95c1n%40googlegroups.com.

Reply via email to