guides:software:git
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
guides:software:git [2020/07/20 00:38] – Add options subsection jhoggard | guides:software:git [2024/07/25 15:01] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 12: | Line 12: | ||
* In the working directory, with changes not yet tracked by git. | * In the working directory, with changes not yet tracked by git. | ||
* In the //staging area//. This is a temporary holding area where the current files are copied, in preparation for adding them to the repository. | * In the //staging area//. This is a temporary holding area where the current files are copied, in preparation for adding them to the repository. | ||
- | * Recorded in the repository. Files in the staging area are moved into a //commit// in the repository, which is a permanent snapshot of the state of all files at that point in time. If we make further changes to any files, these will be untracked changes until will stage and commit them. | + | * Recorded |
(Note that there may also be a //remote repository//, | (Note that there may also be a //remote repository//, | ||
Line 23: | Line 23: | ||
- (Optional) If we have a connection to an archive on a remote repository (on a service like GitLab or GitHub), we can //push// those changes to remote repository. This stage is needed to share the project with others, if we wish. | - (Optional) If we have a connection to an archive on a remote repository (on a service like GitLab or GitHub), we can //push// those changes to remote repository. This stage is needed to share the project with others, if we wish. | ||
- | As a simple example, we will look at the process of setting up a git repository for a simple " | + | As a simple example, we will look at the process of setting up a git repository for a simple " |
- | * First, let's make a directory to store the program in. We'll create a directory '' | + | * First, let's make a directory to store the program in. We'll create a directory '' |
< | < | ||
$ mkdir HelloTest | $ mkdir HelloTest | ||
Line 97: | Line 97: | ||
| | ||
</ | </ | ||
- | * We used the commit message " | + | * We used the commit message " |
+ | ==== Server: GitLab, GitHub, etc ==== | ||
+ | We can also work with a //remote// repository, which holds a copy of all our work on a server. | ||
- | Local repository: files, staging area, repository | + | The department maintains its own GitLab server at codestore.cs.edinboro.edu. |
- | init, add, status, commit | + | === Create and clone === |
- | ==== Server: GitLab, GitHub, etc ==== | + | If you want to set up a remote repository on codestore, you can click the " |
+ | |||
+ | You can select " | ||
+ | |||
+ | Afterwards, you will see instructions for cloning your repository to your local machine, but it is not hard: On your project' | ||
+ | |||
+ | Then on your machine (possibly cslab103), type the following in the directory where you want to clone the repository: | ||
+ | < | ||
+ | git clone < | ||
+ | </ | ||
+ | where ''< | ||
+ | |||
+ | Now you have a local copy of the repository, and by default, it is connected to the remote repository. | ||
+ | |||
+ | However, '' | ||
+ | |||
+ | === Push and Pull === | ||
+ | |||
+ | To send your commits up to '' | ||
+ | < | ||
+ | git push origin master | ||
+ | </ | ||
+ | (The above sends your //master// branch commits to '' | ||
+ | |||
+ | To update your local repository with any changes added to the remote repository, you need to //pull// the files. | ||
+ | < | ||
+ | git pull | ||
+ | </ | ||
+ | This will fetch any commits made on your current branch (probably master) and merge them into your current directory. | ||
+ | |||
+ | You can also separate this into two steps. The first retrieves any new snapshots on the remote repository, and the second merges the changes into your current files. | ||
+ | < | ||
+ | git fetch | ||
+ | git merge | ||
+ | </ | ||
+ | |||
+ | ==== Fork Another Repository | ||
- | Create | + | You may sometimes want to copy someone else's repository on codestore into your very own version of the repository. |
- | Push and pull | + | In GitLab (for example, at codestore), you can click on the " |
- | Fork another repository | + | Then you can clone //your// fork of the project to your own computer, and proceed as usual. |
- | === Setting up SSH Credentials === | ||
==== Setting Options ==== | ==== Setting Options ==== | ||
Line 123: | Line 160: | ||
The following are common tasks to complete using git. Where we refer to GitLab, the same task can be completed with other git servers, such as GitHub, usually with very little or no change. | The following are common tasks to complete using git. Where we refer to GitLab, the same task can be completed with other git servers, such as GitHub, usually with very little or no change. | ||
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
- | * '' | + | * '' |
guides/software/git.1595205528.txt.gz · Last modified: 2024/07/25 15:01 (external edit)