-
Notifications
You must be signed in to change notification settings - Fork 149
git and GitHub FAQ
Ask a question by creating a new topic or post on the DiscussCESM forums!
- How can I clone someone's git clone to my directory on the same machine?
- How can I clone someone's git clone to my directory on a different machine?
- How can I look at someone's PR code on my machine?
Answer: git clone <path_name> [<local_dir>]
where <path_name>
is the location of the source git clone and the optional <local_dir>
is the name of the clone (default is a local directory of the same name as the original).
Answer: git clone ssh://<user>@<machine>:<path_name> [<local_dir>]
where <user>
is your user name on the remote machine, <machine>
is the machine name (e.g., cheyenne.ucar.edu), <path_name>
is the location of the source git clone on the remote machine, and the optional <local_dir>
is the name of the clone (default is a local directory of the same name as the original).
Answer: There are a few ways to do this.
- On GitHub (like looking at any other code on GitHub)
- Add the PR fork to my remote (allows using tools such as
git diff
orgit difftool
with your existing branches or cam_development) - As a clone (standalone clone on your machine).
A first step is to find the link to the fork's branch. Just below the PR is a line that starts with a colored oval (e.g., "Open" in green) and looks something like:
Octocat wants to merge 123 commits into ESCOMP:cam_development from Octocat:amazing-new-feature
Clicking on the last part (Octocat:amazing-new-feature
) will take you to the correct branch where you can browse the code (the first method above). If you want to download that code, click the green "Code" button and then click the clipboard icon. Be sure to take note of the branch name.
- To load this code into your clone, cd to your clone directory, add the PR fork as a new remote, and checkout the branch. For instance:
git remote add octocat https://github.com/octocat/CAM.git
git fetch --no-tags octocat
git checkout octocat/amazing-new-feature
Instead of the checkout
, you can also do diffs:
git difftool origin/cam_development octocat/amazing-new-feature
- If you want to make a new clone with the PR code, simply do:
git clone -b amazing-new-feature octocat https://github.com/octocat/CAM.git octocat_cam
cd octocat_cam
CAM wiki
CAM Documentation
CAM Model Development