From Sinfronteras
Revision as of 12:12, 2 June 2020 by Adelo Vieira (talk | contribs) (GitHub Pages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Installing Git

sudo apt install git

Configuring GitHub

We need to set up the configuration details of the GitHub user. To do this use the following two commands by replacing "user_name" with your GitHub username and replacing "email_id" with your email-id you used to create your GitHub account.

git config --global "user_name"
git config --global "email_id"
git config --global "adeloaleman"
git config --global ""

GUI Clients - Github Desktop

Git comes with built-in GUI tools for committing (git-gui) and browsing (gitk), but there are several Desktop tools for users looking for platform-specific experience:

  • GitHub Desktop (aplicación oficial GitHub):

Hay otras aplicaciones similares a la aplicación oficial GitHub Desktop disponibles para Linux:

Github Desktop

Install GitHub Desktop on Ubuntu

Basics about creating, committing and pushing a repository

  • Go to and click on «New»
  • Repository name: WebApp-CloneOfTwitter
  • ...
  • Click «Create repository»

  • Create a local repository in our computer:

After we create a repository at, we have to create a local repository in our computer:

mkdir nombreDelRepositorio
cd nombreDelRepositorio

# Create the repository
git init
git remote add origin

# In case we want to create a RAADME file
echo "# ProyectoPiloto" >>

# Commit and push the files
git add .
git commit -m "first commit"
git push -u origin master

Ahora, si queremos crear un repository local in our computer para un repository en que ya contiene archivos, al intentar «git push -u origin master» obtendremos el siguiente error:

error: failed to push some refs to ''
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.

Tenemos dos opciones:

1. To clone the repository:

Si queremos preservar los archivos que se encuentran en el repositorio en

git clone

# Or using ssh:
git clone

2. Forzar el «push» a través de la opción «-f»:

Los archivo que se encuentran en serán reemplazados.

git push -f origin master

  • Si nuestro repositorio contiene Branches

En este caso no podremos realizar «commit» and «push» al «master». Tenemos que trabajar en nuestro branch y hacer el «commit» and «push» hacia nuestro branch.

Entonces, desde nuestro repositorio local en nuestra computadora, podemos cambiar de branch de la siguiente forma:

git checkout «branch_name»
git checkout adelo

Luego los «commit» and «push» se deben realizar de la siguiente forma:

git push -u origin adelo

Ignnore - exclure files when commiting or pushing

Debemos crear el file «.gitignore»

Al parecer, se puede crear en el home y puede ser utilizado para excluir files en cualquier repositorio. Yo lo he sin embargo creado en el current repository. En este file simplemente tenemos que escribir los files que queremos excluir.

My basic «.gitignore» looks like this:


However, there can be many different files depending on the project. Actually, Githup will propose you a «.gitignore» file when you create a repository based on the Language, Framework or Library.

For example, for a React project, we have to exclude the «/node_modules» folder. This is how my «.gitignore» file looks like for my React project. I have actually commented the recommended exclusion files because I didn't understand well why they were being excluding. However, it can be important to exclude some of these files; sometimes for security reasons:


### Lo siguiente es el archivo .gitignore generado automaticamente cuando cree el proyecto React
## See for more about ignoring files.
## dependencies
## testing
## production
## misc

If you want to ignore a file that you have committed in the past

For example, if we want to ignore our «» but it has already been committed in the past, you'll need to delete the file from your repository this way:

git rm --cached

Using git rm --cached means that the file will be deleted from your «repository», but will remain in your «working directory» as an ignored file.

My uptoday script

I have also created a «» script to automate the pushing process.

This script is able to optionally take an argument. If you don't give it an argument the «commit comment» will just be "commit"; but you can specify a «commit comment» in the argument of the script. For example:

./                         # This will commit and push the changes using the «commit comment»: "commit"
./ "The navbar was added"  # This will commit and push the changes using the «commit comment»: "The navbar was added"
#! /bin/sh

git add .


if [ -z "$commit" ]
	git commit -m "commit"
	# echo "Please set \$commit"

	git commit -m "$1"
	# echo "Setting up jail at $commit"

git push -u origin master

How to change the URL for a remote Git repository

git remote set-url origin

Git push requires username and password

In the link above there is apparently an explanation about how to avoid typing the username and password every time you push files.

GitHub Pages

Websites for you and your projects. Hosted directly from your GitHub repository. Just edit, push, and your changes are live.

I have done an example:

Another Collaborative and Remote development resources I have been testing

This is not related to GitHub at all. I'm leaving this section here cause I haven't found a better place to it.

Eclipse - Connect to a remote file system

Mount a remote filesystem in your local machine /home/adelo/1-system/3-cloud
sshfs -o reconnect,ServerAliveInterval=5,ServerAliveCountMax=3 /home/adelo/1-system/3-cloud
sshfs -o allow_other /home/adelo/1-system/3-cloud

faster way to mount a remote file system than sshfs: