Remote branches : list and track branches ( git remote -r, git branch -track, -set-upstream-to)Step 7: List the remote branches‘git clone’ checks out just the active checked out branch on the remote server.Let’s have a look at the remote branches:git branch -remote OR git branch -r origin/B1 origin/dev origin/localB1 origin/master origin/prod origin/remoteB2 origin/uatStep 8: List the local branches tracking remote branches$git branch -vv * dev e422743 Merge branch 'localB1' master d45cfd6 another edit from master newBranch 61435ed Adding the authorNOTE: Local branch ‘master’ already set to track ‘origin/master’ when we cloned the repository.Git clone branch: To clone a remote branch use the ‘git checkout Checkout a remote branch as a local branch with the -track flag that sets local branch to track remote branch with the same name.$ git checkout -track origin/dev Branch 'dev' set up to track remote branch 'dev' from 'origin'. remote: Total 27 (delta 0), reused 0 (delta 0), pack-reused 27 Unpacking objects: 100% (27/27), done.Step 2: show remote reposList the remote repository for this local working directory:$git remote originStep 3: verbose and show remote url-List the url of the remote repo $git remote -v origin (fetch) origin (push)‘origin’ is the default remote name assigned by the ‘git clone’ command.This remote reference gives both ‘fetch’ and ‘push’ access to the cloned working directory.Step 4: Add remote repositories-add another remote reference ‘origin2’ to the same commit git remote add origin2 -add a remote reference ‘myProj’ to a different local repository git remote add myProj ~/OneDrive/gitRepos/myProj -List the remotes git remote -vNOTE: Other url protocols such as ‘https’, ‘ssh’, ‘file:///…’ etc can also be used to add remotes.myProj /Users/Divya1/OneDrive/gitRepos/myProj (fetch) myProj /Users/Divya1/OneDrive/gitRepos/myProj (push) origin (fetch) origin (push) origin2 (fetch) origin2 (push)NOTE: Both ‘origin’ and ‘origin2’ points to the same remote url.Step 5: Rename a remote namegit remote rename git remote rename myProj LocalRepo_myProj -list the remotes git remoteLocalRepo_myProj -renamed origin origin2Step 6: Remove a remote repository referenceThis will only remove the remote reference to the repo.-remove the duplicate reference to ‘origin’ repo git remote remove origin2 -List the remotes git remoteLocalRepo_myProj origin3. ![]() warning: redirecting to remote: Enumerating objects: 27, done. Remotesvisualize and add/rename/delete remote refs“remotes” refer to remote connections to other repos.It’s a shortname for a long url or references to a commit, such as a branch, tag, HEAD, remote branch.Unlike Centralized VCS, git manages remote repositories just like any other full git repository.Different repos can be connected with eachother and share the differences of data.Few repos with full access, few with read-only access etc.Step 1: Clone the projectUnder your home directory, run the below git clone command:git clone learnRemotesA new directory ‘learnRemotes’ will be created, this is your working director圜loning into 'learnRemotes'. We shall cover this in detail under the ‘bare repository’ section.2. ![]() Clone repositories – git collaborationThis git clone tutorial shows how to collaborate on githubCommand: git clone: Clones a repository into a new director圜lones the entire existing repo with complete project historycreates a working copycreates a remote connection(reference) to the original repo.Creates and checks out an initial branch that is forked from the cloned repo’s currently active branch.Usage of git clone command:-git clone repository git clone git clone There is repo to repo collaboration, and no central repository:NOTE: If no name is given, a directory will be created with the same name as the remote repository.a) Git protocols can be of any protocol types as: https, http, ssh, remote server, local path git URLs also supports ftp but it is deprecated.b) Clone different repositories#https: git clone #http: git clone #ssh: git clone #Clone from a remote server: git clone #Clone from your local path: git clone file:///local/pathThere is also a –-bare flag to the ‘git clone’ command that creates a bare repository to publish your changes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |