Save changes to GitHub

Prepare the GeoNode fork

cat requirements.txt 
# -e git+https://github.com/GeoNode/geonode.git@4.1.x#egg=GeoNode
  • Click on the Fork button and select the target repository; make sure you uncheck the Copy the master branch only option!

    image

  • Wait for the process to finish. When it is completed, you will be able to see GeoNode in your own repository with the same branches and the same commits as upstream

    image

Add the Fork and Branch to the Code

  • Click on the Code dropdown and copy the new fork URL

    image

  • Go back to the shell and navigate to

    cd /opt/geonode
    
  • Type the following commands

    # Add the new GitHub remote address
    git remote add <a name> <the fork URL>   <-- e.g.: git remote add afabiani https://github.com/afabiani/geonode.git
    
    # Update the .git references
    git fetch --all
    
    # Create a new branch
    git checkout -b geonode_training_4x
    
    # Double check you switched to the correct branch
    git branch
      4.1.x
    * geonode_training_4x
    
    # Push the new branch to your fork
    git push <name of the remote> <name of the branch  <-- e.g: git push afabiani geonode_training_4x
    
  • Example:

    git push afabiani geonode_training_4x
    
    Total 0 (delta 0), reused 0 (delta 0)
    remote: 
    remote: Create a pull request for 'geonode_training_4x' on GitHub by visiting:
    remote:      https://github.com/afabiani/geonode/pull/new/geonode_training_4x
    remote: 
    To https://github.com/afabiani/geonode.git
     * [new branch]          geonode_training_4x -> geonode_training_4x
    

image

Generate a Push Token

  • GitHub will ask you to provide a user/password to perform pushes/commits, but it will force you to create a token

  • To create (or refresh) a token, go to settings

    image

  • Click on Developer Settings

    image

  • Generate a new token

    image

    image

  • Provide a name and expiration date. Select the privileges. The ones below will allow you to push commits to the repository

    image

  • Copy the new token and store it somewhere. Otherwise, you will need to refresh it

    image

Commit the Changes to GitHub

  • Check the repository status

cd /opt/geonode
git status

On branch geonode_training_4x
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   geonode/base/api/serializers.py
	modified:   geonode/base/forms.py
	modified:   geonode/base/models.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	geonode/base/migrations/0061_resourcebase_custom_md.py
	geonode/base/migrations/0062_auto_20210910_1445.py

no changes added to commit (use "git add" and/or "git commit -a")
  • Add the unchecked files to the commit

git add geonode/base/migrations/0061_resourcebase_custom_md.py geonode/base/migrations/0062_auto_20210910_1445.py

git status

On branch geonode_training_4x
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   geonode/base/migrations/0061_resourcebase_custom_md.py
	new file:   geonode/base/migrations/0062_auto_20210910_1445.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   geonode/base/api/serializers.py
	modified:   geonode/base/forms.py
	modified:   geonode/base/models.py
  • Create a commit and push the changes

git commit -a -m " - Added a custom_md field to the GeoNode ResourceBase metadata"
git status

On branch geonode_training_4x
nothing to commit, working tree clean
git log

commit b359f1c49a1196727a6af9fa916cb11b6d28dbdd (HEAD -> geonode_training_4x)
Author: afabiani <alessio.fabiani@geo-solutions.it>
Date:   Mon Sep 13 14:24:52 2021 +0100

     - Added a custom_md field to the GeoNode ResourceBase metadata

commit 911a0f14eb7204c622c807ba877b4a2dce3e3caa (afabiani/geonode_training_4x, 4.1.x)
Author: Toni <toni.schoenbuchner@csgis.de>
Date:   Tue Aug 31 17:57:04 2021 +0200

    added jcaceres85
    
    (cherry picked from commit 5553d1882718d38c742e6e4a86bf1ad51f14fb15)
    
    # Conflicts:
    #       .clabot
[...]
  • Push the changes to the remote repository in the format

    git push <name of the remote> <name of the branch  
    
  • Example

    git push afabiani geonode_training_4x
    
    Enumerating objects: 19, done.
    Counting objects: 100% (19/19), done.
    Delta compression using up to 2 threads
    Compressing objects: 100% (11/11), done.
    Writing objects: 100% (11/11), 1.34 KiB | 684.00 KiB/s, done.
    Total 11 (delta 9), reused 0 (delta 0)
    remote: Resolving deltas: 100% (9/9), completed with 8 local objects.
    To https://github.com/afabiani/geonode.git
       911a0f14e..b359f1c49  geonode_training_4x -> geonode_training_4x
    

Create a new repository for the GeoNode project

The steps are similar to the ones above, except that this time we have to create a brand new repository from scratch instead of forking an existing one.

  • Initialize the working directory as a git repository

    cd /opt/geonode-project/my_geonode
    git init
    
  • Create a new repository on GitHub

    • Go to https://github.com/<name>?tab=repositories (e.g. https://github.com/afabiani?tab=repositories), and create a new repository

      image

    • Provide a name

      image

    • Copy the link

      image

  • Add the repository to the geonode-project

git remote add <a local name> https://github.com/<fork name>/my_geonode.git  <-- e.g.: git remote add afabiani https://github.com/afabiani/my_geonode.git

# Update the refs
git fetch --all

# Create a new branch
git checkout -b main

# Check the status of the local files and add all of them to the commit
git status
git add -A
git status

# Create a new commit along with a message
git commit -a -m " - My GeoNode"

# Finally, push to the repository
git push afabiani main

image