Git GitHub - Team-5/UserGuides GitHub Wiki
#Git / GitHub User Guide #####Select the 'Sign In' button on the GitHub Home page. #####Enter your Username / Email Address and Password.
To begin creating a new repository: Click the 'Create new...' button (looks like a '+' sign at the top left side of the page) and select 'New Repository.'
-
Creating the repository
1. Add a repository name. Try to keep it relatively short and memorable. 2. Optional: Add a description of the repository. 3. Decide whether you want the repository to be public or private. 4. Decide whether to initialize a README or not. You can skip this step it you are importing an existing repository. 5. Click the green 'Create repository' button.
-
Cloning a repository
1. Navigate to the repository you want to clone / download. You can do this by going to "https://github.com/[Repository Owner's username]/[Name of Repository]. 2. Make sure you are on the '<>Code' tab for the repository. 3. Click the green 'Clone or download' button on the left side of the page. 4. Either copy the HTTPS URL for the repository, or click the "Download ZIP" button. 5. enter the clone command into git bash: git clone https://github.com/[Repository Owner's username]/[Name of Repository]
###Adding files or changing repositories and pushing them to GitHub.
Make sure you have downloaded git and navigate to your project directory before using these commands.
-
Commands to create and push a repository from the command line.
git config --global user.name "[Your Name]" git config --global user.email "[YourEmail]@[YourEmail.com]" touch README.md (This will create a README.md file) git init (This will initialize the repository) git add README.md git commit -m "[Describe your comments or changes]" git remote add origin https://github.com/[Your Username]/[Name of Repository].git git push -u origin master
-
Commands to push an existing repository from the command line.
git remote add origin https://github.com/[Your Username]/[Name of Repository].git git push -u origin master
-
Commands to add file changes to a repository and commit them from the Command Line.
Option 1: git add [File] Option 2: git add [Directory] Option 3: git add -p (The previous option is an interactive staging session that lets you choose parts of a file to add to the next commit. Presents you with chunks of changes and prompt you for a command. Use 'y' to stage the chunk, 'n' to ignore the chunk, 's' to split it into smaller chunks, 'e' to manually edit the chunk, and 'q' to exit.) Option 4: git add -A (This will stage all changes made) git commit -m "[insert message about your commit]" git push -u origin master
-
Commands to change the URL of a cloned / downloaded repository.
git remote -v (This will show you the current URL destination) git remote set-url origin https://github.com/[Your Username]/[Name of Repository].git NOTE: This should change the cloned repository's URL to your repository's URL. You can use git remote -v again to check. git push -u origin master (This will push the repository to the new URL on github).
###Deleting an existing repository.
Note: This action cannot be undone.
1. Navigate into the repository that you want to delete.
2. Click the 'settings' tab and scroll all the way down to the 'danger zone.'
3. Click the 'Delete this repository,' enter the name of the repository.
4. Now you can confirm that you understand the consequences of deleting
the repository and it will then be deleted.
###Merging files using GitHub.
If you are working with multiple people on the same repository, merging is necessary to avoid and conflicting changes. If the repository and its files have not been changed while you were working on them, then merging is not necessary.
1. Use the 'git merge' command to pull the changes to your files.
2. Now, you will have to go through all the changed files to ensure
that there are no conflicts between your changes and your partner's
changes.
3. Once this is complete you may save, add, commit, and push your work.