|
| 1 | +# Quick git how to |
| 2 | + |
| 3 | +Quick instructions on how to contribute to this repo from the command line. |
| 4 | + |
| 5 | +Please see link to other resources below. |
| 6 | + |
| 7 | +## 1. Clone the repo on your local machine |
| 8 | + |
| 9 | +``` |
| 10 | +git clone git@github.com:Z80coder/datalog-cpp.git |
| 11 | +``` |
| 12 | + |
| 13 | +You should now have a `datalog-cpp` folder. |
| 14 | + |
| 15 | +``` |
| 16 | +cd datalog-cpp |
| 17 | +``` |
| 18 | + |
| 19 | +## 2. Update the master branch |
| 20 | + |
| 21 | + |
| 22 | +``` |
| 23 | +git checkout master |
| 24 | +git pull |
| 25 | +``` |
| 26 | + |
| 27 | +## 3. Create a new branch for your work |
| 28 | + |
| 29 | +You will develop your code in your own branch. First you need to create it. |
| 30 | + |
| 31 | +``` |
| 32 | +git checkout -b your_branch_name |
| 33 | +
|
| 34 | +git push --set-upstream origin your_branch_name |
| 35 | +``` |
| 36 | + |
| 37 | +## 4. Or switch to your existing branch for your work |
| 38 | + |
| 39 | +If you already done the step above, then ensure you are in your branch when you write code. |
| 40 | + |
| 41 | +``` |
| 42 | +git checkout your_branch_name |
| 43 | +``` |
| 44 | + |
| 45 | +## 5. Do some coding |
| 46 | + |
| 47 | +Work as normal |
| 48 | + |
| 49 | +## 6. Commit your changes |
| 50 | + |
| 51 | +Type |
| 52 | +``` |
| 53 | +git status |
| 54 | +``` |
| 55 | +to check which files you've added or changed. Note the files you want to commit at this time, then: |
| 56 | +``` |
| 57 | +git add newfile1 newfile2 |
| 58 | +``` |
| 59 | +Then commit the changes |
| 60 | +``` |
| 61 | +git commit |
| 62 | +``` |
| 63 | + |
| 64 | +## 7. Push your changes to GitHub |
| 65 | + |
| 66 | +All you've done so far is declare some changes. You haven't yet pushed them to the GitHub repo. Let's do that now. |
| 67 | + |
| 68 | +``` |
| 69 | +git push |
| 70 | +``` |
| 71 | + |
| 72 | +You can keep adding, committing and pushing until you're ready to open a pull-request (with the intent of merging the changes in your branch into the `master` on the repo). |
| 73 | + |
| 74 | +## 8. Open a pull-request |
| 75 | + |
| 76 | +Go to https://github.com/Z80coder/datalog-cpp |
| 77 | + |
| 78 | +Click on the `Branch` button and look for `your_branch_name`, and then click on it. |
| 79 | + |
| 80 | +You should see a `New pull request` button. Click it and follow the user-interface prompts to create a pull-request. |
| 81 | + |
| 82 | +Once reviewed, your branch will be merged. You can contribute a new collection of changes by returning to `Create a new branch for your work` above. |
| 83 | + |
| 84 | +## Other resources |
| 85 | + |
| 86 | +- Microsoft Visual Studio has git support built in, and there's a GitHub plugin for Visual Studio to enable direct cloning from GitHub repos. |
| 87 | + |
| 88 | +- Microsoft Visual Code also has plug-in extensions that support Git |
| 89 | + |
| 90 | +- https://guides.github.com/ has some useful guides. |
| 91 | + |
| 92 | +- Also, there's a GitHub Desktop app: https://desktop.github.com/ |
0 commit comments