Basic Git
What is a Git Repository
A Git repository is a virtual storage of your project. It allows you to save versions of your code, which you can access when needed. 1
Git Clone
git clone is a Git command line utility which is used to target an existing repository and create a clone, or copy of > the target repository. … Cloning a local or remote repository. Cloning a bare repository. Using shallow options to partially clone repositories. Git URL syntax and supported protocols. If you are using the https method, you will be prompted for your username and password at this point. 1
Example:
https://code.vt.edu/joyh/rocksat.git
If you are using the ssh method, authorization will be automatically done.
Example:
git clone git@code.vt.edu:joyh/rocksat.git
open up terminal, and use the method selected:
git clone <clone url>
press enter If you added a passphrase, you will be prompted for that passphrase. After the contents are downloaded, cd into that repo. For the demo one above, the directory is “rocksat”.
cd <reponame>
Git Status:
The git status command displays the state of the working directory and the staging area. It lets you see which changes > have been staged, which haven’t, and which files aren’t being tracked by Git. Status output does not show you any information regarding the committed project history.1
git status
create a new branch so that you keep the original separate from changes you make.
git checkout -b <yourBranchName>
copy your site files and folders into the git repo directory
(Linux )
cp -R /path/to/your/site/files/site .
show branch you are on:
git branch
edit or create files
add edited/changed/new files to push
git add error.html
commit the files to be pushed, with a comment
Git Commit
The git commit command is one of the core primary functions of Git. Prior use of the git add command is required to select the changes that will be staged for the next commit. Then git commit is used to create a snapshot of the staged > changes along a timeline of a Git projects history.1
git commit -m 'Add error.html file'
push the file(s) to git repo
Git Push
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. … Remote branches are configured using the git remote command. > Pushing has the potential to overwrite changes, caution should be taken when pushing.1
git push origin <yourBranchName>
go to code.vt.edu repo and create a merge request
Submit merge request to master
Add an assigned person to verify the to be merged item
The assigned verifier will click the “merge” to merge the items(s)
The items will be added to the main repo and changes will be added to the main site. While the site is in “stage”, the changes will be basically instantaneous. Once the site is “launched” or using the *.vt.edu name, the changes will take a little bit of time.
- Git Commands: www.atlassian.com/git
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.