| 1 | = Github administration = |
| 2 | |
| 3 | === Install Git and create a Github account === |
| 4 | |
| 5 | To see if you already have Git installed, open up your terminal application. |
| 6 | |
| 7 | Once you've opened your terminal application, type git version. The output will either tell you which version of Git is installed, or it will alert you that git is an unknown command. If it's an unknown command, read further and find out how to install Git. |
| 8 | |
| 9 | Install git: |
| 10 | |
| 11 | Debian/Ubuntu |
| 12 | |
| 13 | Git packages are available using `apt`. |
| 14 | |
| 15 | It's a good idea to make sure you're running the latest version. To do so, Navigate to your command prompt shell and run the following command to make sure everything is up-to-date: `sudo apt-get update`. |
| 16 | |
| 17 | To install Git, run the following command: `sudo apt-get install git-all`. |
| 18 | |
| 19 | Once the command output has completed, you can verify the installation by typing: `git version`. |
| 20 | |
| 21 | To create the github account: |
| 22 | |
| 23 | Navigate [https://github.com] and signup with your details |
| 24 | |
| 25 | === Install source tree on your computer === |
| 26 | |
| 27 | === Create a local Git repo === |
| 28 | |
| 29 | ===== Every git repository has three trees. A working directory, Index and Head. ==== |
| 30 | |
| 31 | - Working directory: It contains the actual project files. |
| 32 | |
| 33 | - Index: It is the staging area where you add the project files that needs to be committed. |
| 34 | |
| 35 | - Head: Head is where the reference to you previous commit exists. |
| 36 | |
| 37 | git init is one way to start a new project with Git. To start a repository, use either `git init` or `git clone` - not both. |
| 38 | |
| 39 | To initialize a repository, Git creates a hidden directory called `.git`. That directory stores all of the objects and refs that Git uses and creates as a part of the project's history. This hidden `.git` directory is what separates a regular directory from a Git repository. |
| 40 | |
| 41 | {{{ |
| 42 | git init: One Person Starting a New Repository Locally |
| 43 | git clone: The Remote Already Exists |
| 44 | }}} |
| 45 | |
| 46 | === Add a new file to the repo === |
| 47 | === Add a file to the staging environment === |
| 48 | |
| 49 | === Create a commit === |
| 50 | === Create a branch === |
| 51 | === Create a new repo on Github === |
| 52 | === Push a branch to GitHub === |
| 53 | === Create a pull request === |
| 54 | === Merge a pull request === |
| 55 | === Get changes on your Github back your computer === |
| 56 | |
| 57 | ==== Committing new changes to the repository (commit): ==== |
| 58 | |
| 59 | Once you have added all the files to the staging area, you can commit the changes with a reference message using the “-m” flag as shown below. |
| 60 | |
| 61 | git commit -m “my first commit” |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | ==== Checking out a repository ==== |
| 69 | |
| 70 | You can create a copy of your git repository using the clone command. Execute the following command to clone your project directory. |
| 71 | |
| 72 | `git clone /path/to/project-repository` |
| 73 | |
| 74 | |
| 75 | |
| 76 | ==== Adding file to the staging area: (add) ==== |
| 77 | |
| 78 | `git add <filename>` |
| 79 | |
| 80 | Let’s say you want to add all the files in your project directory to the staging area. Execute the following command to do the same |
| 81 | |
| 82 | `git add --all` |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |