Cloning Code from a Repository
Introduction
Once you have installed Git on your computer, you are ready to download the code repository for the first time. This is called “cloning” in Git.
The git clone command without any options specified clones the entire repository, which is all releases on all branches. If you are cloning a repository that is established with many releases, it would be better to do a shallow clone instead. Attempting a full clone is very expensive on time and bandwidth and common mistake made by Git beginners.
You can clone just a specific release tag by using both the --depth and -b option together in your clone command. See - Shallow Cloning for detailed examples of how to do this.
Linux
Linux builds cannot be cloned to Windows computers due to file name and path length limitations on Windows computers. If you are downloading a Linux build, be sure to clone to a Linux machine to ensure all files are checked out.
To clone the repository in Linux, follow these steps:
1.Open a Terminal
2.Navigate to the location you wish to have your files downloaded to
3.Enter the following command:
time git clone URL_Copied_From_QPM {optional_folder_name}
4.You will be challenged for your credentials. Provide them.
5.Allow the clone to complete
6.Once the terminal is finished, you can see the code on your computer and move it to where you need it.
Windows
To clone the repository in Windows, follow these steps:
1.In Qualcomm® Package Manager, navigate to the repository you wish to clone
2.Copy the Git URL to your clipboard
3.In Windows Explorer, navigate to a location on your local machine’s hard drive that you wish to store the repository to
4.Right-click and choose “Git Bash Here”.
5.A Git Bash terminal screen will open
6.Type in the following command:
time git clone URL_Copied_From_QPM {optional_folder_name}
Note! Do not clone a new repository from within an existing repository. Make sure that there is no Git branch displayed at the path you attempt to clone to.
1.Press [Enter] (Note: If you did not set up your _netrc file, you will be challenged for your credentials)
2.Wait for the clone to complete. A completed clone will return you to the Git Bash prompt in your terminal
Once the clone is complete, you do not need to do it again. To receive subsequent updates, you will use a different Git command: pull
Checkout
To switch to a specific release tag in your repository, you can use the git checkout command after your full clone or latest pull command is completed to switch to a specific release after you have updated your local copy of the repository.
Cloning and switching to a Branch or release tag
Clone entire repository and immediately checkout a particular branch or release tag:
time git clone -b r12345.1 http://abc.net/git/abc.git
Expected output (when checking out a tag):
[user@system tmp]$ git clone -b r12345.1 http://abc.net/git/abc.git
Cloning into 'abc'...
done.
Note: checking out '93450512977fa0144e70cba845d042b0b28528c3'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new-branch-name
Expected output (when checking out a branch):
[user@system tmp]$ git clone -b master http://abc.net/git/abc.git
Cloning into 'abc'...
done.
This command clones the entire repository into a newly created directory and places it in the specified branch. This can be done when setting up the project for the first time. This is equivalent to a clone followed by a checkout to a specific branch.
This is convenient for when you are to start work on a specific branch only, not necessarily the latest. This may be the situation when your project has entered the Technical Acceptance (TA) state and you are waiting to accept targeted changes on newer releases (master).