Difference between revisions of "Git Cheat Sheet"

From Nearline Storage
Jump to navigation Jump to search
m
m
 
Line 32: Line 32:
 
: <code>$ git push -u origin new_branch_name</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
 
: 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

Create A New Project Repository

  1. Go to https://github.com/new and create a new repository (project)
  2. 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]