My Blog

Create a Repo in your Github space. Add a Readme and a License (the MIT License is what I like to use).

At the same time, create a new local directory (folder) in your computer, wherever you want.

  • Step 1: In Bash, navigate to your newly created folder with the cd command
  • Step 2: Initialize Git in this new project folder git init
  • Step 3: Add your remote pointer for this folder git remote add origin https://github.com/your_github_page/your_new_repo_name
  • Step 4: Check that the pointer is ok by doing git remote -v
  • Step 5: If the pointer is ok, fetch the changes from the remote (the license and the readme files) git fetch origin
  • Step 6: Merge your local changes (empty directory) with the remote fetched files git merge origin/main
  • Step 7 (optional): If you already added some files to your local directory you may need to force the merge git merge origin/main --allow-unrelated-histories
  • Step 8: To push the current branch and set the remote as upstream git push --set-upstream origin main
  • You're ready to go now!

Create a Repo in your Github space. Create a Token and save it somewhere so that it doesn't get lost as you will need it later.

  • Step 1: from google.colab import drive
    drive.mount('/content/drive')
  • Step 2: !apt-get install git
  • Step 3: %cd /content/drive/MyDrive/Github/
  • Step 4: !git init mysql_sales_repo
  • Step 5: %cd mysql_sales_repo
  • Step 6: !git status
  • Step 7: !git config --global user.email "maite.lizarraga@gmail.com"
    !git config --global user.name "MaiteLizarraga"
  • Step 8: !git remote add origin https://github.com/MaiteLizarraga/mysql_sales_repo.git
  • Step 9: !git remote -v
  • Step 10: !git branch -M main
  • Step 11: !git remote set-url origin https://MaiteLizarraga:mysql_exam@github.com/MaiteLizarraga/mysql_sales_repo.git
  • Step 12: !git fetch origin
  • Step 13: !git pull --rebase origin main

Create a Repo in your Github space with Readme.md file.

Don't forget to pull the readme file into your local folder. To do so:

  • Step 2: git init
  • Step 3: point to your remote repository by doing git remote set-url origin my/remote/repository
  • Step 3: git fetch origin
  • Step 4: git commit -am "readme file"

If you already have a local repository that you want to push to this new GitHub repository, follow these steps:

  • Step 1: cd /path/to/your/local/repo
  • Step 2: git remote add origin https://github.com/your-username/specific_project_repo.git
  • Step 3: git push -u origin main

Add the Repository as a Submodule to Your Main Repository.

  • Step 1: cd ..
  • Step 2: git remote -v
  • Step 3: git remote set-url origin https://github.com/MaiteLizarraga/specific_project_repo.git
  • Step 4: git submodule add https://github.com/MaiteLizarraga/specific_project_repo.git
  • Step 5: git submodule init
  • Step 6: git submodule update
  • Step 7: git add .
  • Step 8: git commit -m "added new submodule edl_univariate_food"
  • Step 9: don't forget to set-url to your main repository!!git remote set-url origin https://github.com/MaiteLizarraga/main_repo.git
  • Step 10: git push origin main
  1. Dangling Commits: These are commits that are not reachable from any branch or tag. They may be remnants of previous changes or commits that were removed from the active branches.
  2. Dangling Trees: These are trees (representing file states) that are not referenced by any commit. They often accompany dangling commits.

Dangling objects are usually harmless and often occur when you rebase or amend commits, force-push changes, delete branches without merging them.

  • Step 1: View dangling commits: git show dangling-commit-hash
  • Step 2: Option 1: Restore dangling commits git checkout -b new-branch-name dangling-commit-hash
  • Step 3: Option 2: Clean-up dangling objects: git gc --prune=now
  • Dangling commits and trees are not harmful unless they are consuming significant disk space or are part of lost work. Git will automatically clean them up over time with its garbage collection (git gc).

Adding programming languages that are not automatically detected by Github can help you boost your stats.

  • Step 1: Initialize Your Local Repository cd /path/to/your/local/folder git init
  • Step 2: Add the Remote Repository git remote add origin https://github.com/username/repository.git
  • Step 3 Fetch Repository Contents: git fetch origin
  • Step 4: Check Out the Remote Branch git checkout -b main origin/main
  • Step 5: Pull Changes git pull origin main

If you're getting an error when trying to push your local changes into a remote repository in Github as in the image below:

  • you just have to check the remote url by doing git remote -v
  • and in case you're pointing at the correct repo, you can force the push by doing git push --force origin main.

You can make git don't track some files or folders:

  • Step pre: create a gitignore file it the project doesn't have one
  • cd path_to_the_repo touch .gitignore
  • Step 1: Open the .gitignore file and add the folder or the file.
  • If it's a folder: /folder_name/
  • If it's a file: filename.txt
  • Step 2: Stop the tracking by Git git rm -r --cached my-directory/
  • step 3: git add .gitignore git commit -m "Update .gitignore" git push