|
|
|
# Setup
|
|
|
|
|
|
|
|
1. Open Git Bash. (Type "bash" in start menu)
|
|
|
|
2. run `ssh-keygen`
|
|
|
|
- accept the defaults by pressing enter three times
|
|
|
|
3. Go to the repository for your class
|
|
|
|
4. Follow the git global setup instructions. Examples are below. Replace John Doe with your own name.
|
|
|
|
- **Important Note:** *You will need to do this for every computer you have not done this for*
|
|
|
|
- `git config --global user.name "John Doe"`
|
|
|
|
- `git config --global user.email "john.doe@students.pcci.edu"`
|
|
|
|
- additionally: `git config --global core.editor notepad` to use notepad for your commit message editor
|
|
|
|
5. make a `stuff` directory by running `mkdir stuff`
|
|
|
|
5. Go into this folder by doing `cd stuff`
|
|
|
|
6. Clone your repository for your class `git clone git@gitlab.studentnet.int:000000/cs101-1.git`
|
|
|
|
7. Change directory into this folder `cd cs101-1`
|
|
|
|
8. You can now put files here and push them to your repository using the normal git method.
|
|
|
|
9. Finally, run `cd ../..` (going back to your home directory) and run `explorer ~/.ssh`
|
|
|
|
10. Copy the two id_rsa files to `\\labfiles\homes\<username>\.ssh` (replacing <username> with your ID number)
|
|
|
|
- Close this window when you are done and go back to the bash prompt
|
|
|
|
|
|
|
|
# Basic Git commands
|
|
|
|
|
|
|
|
## Syntax Key
|
|
|
|
|
|
|
|
Note: This is not a git command.
|
|
|
|
|
|
|
|
`<argument>` - On its own means that it is required
|
|
|
|
|
|
|
|
`[<argument>]` - means that it is optional (or at least sort-of optional)
|
|
|
|
|
|
|
|
## help
|
|
|
|
|
|
|
|
Syntax: `git help [<command>]`
|
|
|
|
|
|
|
|
This command will show you the documentation on how to use each command. Sometimes it shows too much information, which is why you have the information below.
|
|
|
|
|
|
|
|
## clone
|
|
|
|
|
|
|
|
Syntax: `git clone <url> [<folder>]`
|
|
|
|
|
|
|
|
Clone is for making a local repository of the file. If you specify a folder, it will make a new folder with that name instead of doing the default behavior of using the repository's name. This is usually only ran once per computer.
|
|
|
|
|
|
|
|
## pull
|
|
|
|
|
|
|
|
Syntax: `git pull [<remote repository> [<branch>]]`
|
|
|
|
Normal **First-time** Use: `git pull -u origin master`
|
|
|
|
Normal Use after using above command: `git pull`
|
|
|
|
|
|
|
|
This pulls from the specified repository and branch. If you have set your upstream by using `-u`, you don't have to specify the remote and branch if that is where you want to pull from. You only need to do `-u` once per repository clone.
|
|
|
|
|
|
|
|
## add
|
|
|
|
|
|
|
|
Syntax: `git add <list of files separated by space>`
|
|
|
|
Normal Use: `git add .` - this adds everything including all changes, deletions, and new files.
|
|
|
|
|
|
|
|
This command adds the files to a
|
|
|
|
|
|
|
|
## commit
|
|
|
|
|
|
|
|
Syntax: `git commit [other arguments]`
|
|
|
|
|
|
|
|
When you only have a one-liner commit message, you can use `-m "message"`.
|
|
|
|
|
|
|
|
If you want to commit all _changed_ files, you can put `-a` on the end of the command line.
|
|
|
|
|
|
|
|
## push
|
|
|
|
|
|
|
|
Syntax: `git push <remote> <branch>`
|
|
|
|
Normal Use: `git push origin master`
|
|
|
|
|
|
|
|
This pushes all the commits to the remote branch. If your remote repository has changed, you will need to run `git pull` first. |