User Tools

Site Tools


programing:git

Git Cheat Sheet

NOTE: Even as a database guy, you still should check in your scripts, etc..

A Good reference: https://education.github.com/git-cheat-sheet-education.pdf

Working in the Master Branch

If doing work in the master branch

  • cd <directory>
  • git pull origin master (NOTE: master is now main)
  • git add –all
  • git commit
  • git push origin master (NOTE: master is now main)

Creating a branch and merging changes

           mike branch
     /---------------------->
    /                        \ 
---O--------------------------O------------>
   |                          |
 branch                     merge              
  • cd <directory>
  • git branch mike_branch
  • or
  • git checkout -b mike_branch
  • git status
  • git add .
  • git commit -m “some comments”
  • git push origin mike_branch

This pushes the changes from the mike branch to upstream on github

Scenario

Git complains about a big file after you do a commit.

  • git rm –cached scripts/restore/bigfile.dat
  • rm 'scripts/restore/bigfile.dat'
  • git commit –amend –no-edit
  • git push origin master (or main)

Cloning a Repo

  • cd to the directory you want to clone to
  • git clone https://github.com/<project>
  • git config –global user.email “your email”
  • git config –global user.name “first last”
programing/git.txt · Last modified: by mlivolsi