Git Bash Help - Autonomous-Motorsports-Purdue/Electrical_Documentation GitHub Wiki

Git Bash Help:

This document will try to outline the process of sharing files through git.  It is a working document so if there is information presented that you think is incorrect, it probably is :)

Navigating to the desired directory:

cd → this is used to "change directory"

            entering this command with no arguments will navigate you to your home directory

cd .. → this will navigate you back to the parent directory

cd /home/user/documents → this will navigate you all the way to this "documents" folder

            Note: after you have typed "cd" you can press tab at any time to auto-complete the directory that you are trying to change into. (ex: start typing cd docu turns into cd documents

Viewing where you are in the filesystem

ls →  this will "list" all of this files in the current folder

ls - a → this will list all files, including hidden files in the current folder

ls -l → this will list all files, as well as their most recent edit time, and their current permissions

pwd → this will "print working directory" aka show you the current file path that you are in

File management:

mkdir → this will create a new directory in the current folder

rmdir → this will remove a directory if it's empty, and warn that it's not empty if not empty

rm -r → this will remove a directory and all of its contents if there are items inside it (however, it will ask for confirmation on every item)

rm -rf Does the same as rm -r, except doesn't ask for confirmation on anything

Setting up Git:

navigate to the location that you want to download the git files in your file system (documents folder...)

git clone <https://github.com/username/repo.git> → use the URL for the AMP GitHub to clone this into your local computer

git reset --hard origin: will make your files look like they do on GitHub

moving files to a different directory in git: tutorial link

            move files on computer

            git add .

            git status → check to make sure that it says rename not delete and create new stuff

            git commit -m "message here"

            git push origin

For a fuller git rundown, check the slides here

Instructions for making commits and pushing to GitHub:

  1. pull from Github (updates your files with the online repository) → git pull origin

  2. DO THIS BEFORE YOU START WORKING AS IT WILL CLEAR ANY OF YOUR LOCAL CHANGES

  3. make changes (using kicad, coding, etc.)

  4. as you go you commit the files using -m to describe the changes you have been making

  5. git status -> shows untracked files

  6. git add → add the files to git

  7. git add . → will add all of the tracked files (use this only if you know you want to add everything

  8. git add * → will add all files, including untracked files (don't use this unless you really want to add a brand new file to the GitHub)

  9. git commit -m ""

  10. Note you can commit files multiple times before pushing.  The push is like your final check off from working.  Commit often, Push only once in a while

  11. git push origin

Other Useful Git commands

(feel free to add new ones as you go)

            git show → shows detailed information about the last commit

⚠️ **GitHub.com Fallback** ⚠️