Git commands

Overview of basic git commands

Content of page:

  1. Add
  2. Log
  3. Name and email
  4. Status
  5. Commit
  6. Push
  7. Pull
  8. Attach remote repo
  9. Cherry
  10. Manual clone
  11. Clone into folder
  12. Go into the a folder
  13. Using nano
  14. Escaping a terminal task


Adds files to a commit git add * Caution: when you delete a local file, don’t use: git add *, you must specify the exact file


Get the latest log of what has changed, less verbose with pretty oneline
git log --pretty=oneline

Set your name and email

git config --global  
git config “username”


get the current status git status


Current changes w/ msg git commit -m "created index file"


Uploads the current from the local git commits to the remote git
git push origin master
Caution: you may want to do a “git fetch origin master” after a push, to arrive at the same point in time as the remote, as an alternative you can just push again and you will arrive at the the same point in time as the remote.


Download remote commits to local repo

git pull origin master
/usr/local/git/bin/git push master

In the simplest terms, “git pull” does a git fetch followed by a git merge.

Attach remote repo:

Attach a remote location to the local git git remote add origin

git remote rm origin    
git remote add origin '' 


git remote set-url origin  
git remote set-url origin  


Can be used to assert if there are any local commits ready to be pushed
git cherry -v master

Manual clone

supports pre existing files in a folder

"git init" <--Installs the invisible .git folder   
"git remote add origin" <-- attach a remote repo  
"git fetch origin master" <--Download the latest .git data  
"git checkout master" <-- Downloads all the **files** from the remote repo  
"git fetch origin master" <-- Again to download the latest .git data  

Clone into folder:

Caution: Folder must be empty, Can’t have preexisting files
git clone /Users/John/test

Go into the a folder

The tilde char represents the user folder: (use ../to get backward)
cd ~/Desktop/test

Escaping a terminal task

ctrl + z

Using nano

Use nano as git text editor git config --global core.editor "nano"

Very good: And also the git pocket ref book