oreoval.blogg.se

Git checkout local branch
Git checkout local branch






€¦and that the repository takes a long time to clone perhaps it has a large history, or there’s a slow network link in the way. Some process requires you to clone the same repository frequently Several people with access to the same filesystem want clones of the same repository or You want to have checkouts of multiple branches of the same project at once or You can also add the other repository with git remote add, then use git fetch -all remote to pull over the objects you need.Īnother issue with shared clones is garbage collection: if garbage collection is later run on the remote and by then it has removed some refs you still have, objects that are still part of your history may just disappear, again leading to “database corrupted” errors on your side.

git checkout local branch

git/objects/info/alternates if you have another local copy. If you have to recover from accidentally deleting the origin, you can edit. If you know you’re going to remove the origin repository, you can use git repack -a in the clone to force it to copy all the objects it needs into its own database. It’s important to keep in mind, though, that the clone is now dependent on the origin repository to function if the origin is not accessible, Git may abort, complaining that its object database is corrupted because it can’t find objects that used to be there. New objects you create in the clone are added to its own database the clone never modifies the origin’s database via this link. Initially, the object database of the clone is completely empty, because all the objects it needs are in the origin. Rather than either copy or link files between the origin and clone repositories, this simply configures the clone to search the object database of the origin in addition to its own. With the long form you can also give a TCP port number for the server, e.g., ssh://:2222/foo.Īn even faster method when cloning a local repository is the -shared option. You can specify the SSH program to use with the environment variable GIT_SSH (the default is, unsurprisingly, ssh). If the path is relative (no leading slash), then it is usually relative to the home directory of the login account on the server, though this depends on the SSH server configuration. Git will also automatically use SSH if you use the ssh URL scheme ( ssh://), or give the repository as this uses SSH to run git upload-pack on the remote side. Git supports a number of transport schemes natively to access remote repositories, including HTTP, HTTPS, its own git protocol, FTP, FTPS, and rsync. You can specify the remote repository with a URL as shown, or with a simple path to a directory in the filesystem containing a Git repository. For example, foo stays foo, but foo.git and bar/foo also become foo. If you give a second argument, Git will create a directory with that name for the new repository (or use an existing directory, so long as it’s empty) otherwise, it derives the name from that of source repository using some ad hoc rules. You can view and manipulate remotes with git remote a repository can have more than one remote with which it synchronizes different sets of branches.Īfter cloning the remote repository, Git checks out the remote HEAD branch (often master) you can have it check out a different branch with -b branch, or none at all with -n: $ git clone

git checkout local branch

We call the first repository a “remote” (even if it is in fact on the same host), and by default, this remote is named origin you can change this with the -origin (-o) option, or with git remote rename later on. The git clone command initializes a new repository with the contents of another one and sets up tracking branches in the new repository so that you can easily coordinate changes between the two with the push/pull mechanism.








Git checkout local branch