Difference between revisions of "Git Cheat Sheet"
Jump to navigation
Jump to search
m |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 17: | Line 17: | ||
<code>$ git commit -a -m "Description"</code> | <code>$ git commit -a -m "Description"</code> | ||
<br /><code>$ git push</code> | <br /><code>$ git push</code> | ||
+ | |||
+ | === Submit Changes To A Project You Don't Own === | ||
+ | |||
+ | Create a pull request: | ||
+ | |||
+ | : Click the <code>Fork</code> button in the project on the GitHub web site to make your own copy of the project in your repository | ||
+ | : <code>$ git clone https://github.com/dlk3/projectname.git</code> - get a local copy of the fork | ||
+ | : <code>$ git checkout -b new_branch_name</code> - create a new branch to work with in your repo | ||
+ | : <code>$ git remote add upstream https://github.com/ownername/projectname</code> - link to the original project | ||
+ | : <code>$ git remote set-url origin git@github.com:dlk3/projectname.git</code> - switch to SSL authentication | ||
+ | : Make whatever changes you need to | ||
+ | : <code>$ git status</code> - check for changes that need to be committed | ||
+ | : <code>$ git commit -a -m "Descriptive text"</code> | ||
+ | : <code>$ git push -u origin new_branch_name</code> | ||
+ | : The upstream project will now have a <code>Compare & pull request</code> button that you can use to submit a pull request to the upstream project for your changes | ||
+ | |||
+ | === Update local copy of a forked project with changes made in the parent project === | ||
+ | |||
+ | <code>$ git remote add upstream git@framagit.org:medoc92/recoll-we.git</code> | ||
+ | <br /><code>$ git fetch upstream</code> | ||
+ | <br /><code>$ git checkout master</code> | ||
+ | <br /><code>$ git rebase upstream/master</code> | ||
+ | <br /><code>$ git push origin master [--force]</code> | ||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Bash]] | [[Category:Bash]] |
Latest revision as of 13:53, 20 April 2021
Contents
Create A New Project Repository
- Go to https://github.com/new and create a new repository (project)
- Create a directory on the local workstation and populate it with the source files, then in that directory do:
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin git@github.com:dlk3/projectname.git
$ git push -u origin master
Pull Down Changes Made At Remote Repository
$ git pull origin master
Push Local Changes Up To Remote Repository
$ git commit -a -m "Description"
$ git push
Submit Changes To A Project You Don't Own
Create a pull request:
- Click the
Fork
button in the project on the GitHub web site to make your own copy of the project in your repository $ git clone https://github.com/dlk3/projectname.git
- get a local copy of the fork$ git checkout -b new_branch_name
- create a new branch to work with in your repo$ git remote add upstream https://github.com/ownername/projectname
- link to the original project$ git remote set-url origin git@github.com:dlk3/projectname.git
- switch to SSL authentication- Make whatever changes you need to
$ git status
- check for changes that need to be committed$ git commit -a -m "Descriptive text"
$ git push -u origin new_branch_name
- The upstream project will now have a
Compare & pull request
button that you can use to submit a pull request to the upstream project for your changes
Update local copy of a forked project with changes made in the parent project
$ git remote add upstream git@framagit.org:medoc92/recoll-we.git
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
$ git push origin master [--force]