Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git Back to Basics CodeMash 2020

Git Back to Basics CodeMash 2020

Have you written code that worked, then broke it, only to not remember what the working code was?
Git, a version control application could be the solution you are looking for. Git can help you to track changes in your projects, go back to when your code is working, or even find out where it broke. You can use it in collaboration with a team or as the only developer on a project.
Learn the commands that are used every day as well as a few that can help you recover from mistakes.

Angel Thomas

January 10, 2020
Tweet

More Decks by Angel Thomas

Other Decks in Programming

Transcript

  1. ABOUT ME Angel Thomas Software Developer 
 Center for Information

    Management @starangel75
 https://speakerdeck.com/astahre/git-back-to-basics-codemash-2020
  2. ?

  3. TYPES OF VERSION CONTROL Old School: We just saved another

    copy with a slightly different name
  4. GIT VOCABULARY Repository: a central location in which data is

    stored and managed Fork: a copy of a repository on a remote server
  5. GIT VOCABULARY Repository: a central location in which data is

    stored and managed Fork: a copy of a repository on a remote server Clone: a local copy of a repository
  6. INIT git init Creates a new git repository. This can

    be an empty project or to convert an existing project.
  7. CONFIG git config --global --edit Edit the git configuration file.

    These changes will be made in the default editor
  8. CONFIG git config --global user.name “Angel Thomas” git config --global

    user.email [email protected] Set identity information for configuration file without opening the editor
  9. CLONE git clone hosting-service.com/username/repository-name (this can be ssh or https)

    Download a copy of a repository and create a local copy
  10. NEW IN GIT 2.23 git switch <branch> Switch branches. This

    would replace checkout. * This is experimental and may change
  11. CONFIG . . AGAIN git config --global alias.co checkout git

    config --global alias.br branch git config --global alias.st status Set some aliases
  12. FETCH git fetch <remote> <branch> Fetch any commits that are

    on the remote repository that are not in the local repository
  13. COMMIT git commit --amend no-edit Any file changes made will

    be added to the commit without changing the commit message
  14. COMMIT git commit --amend -m “commit message” Change the commit.

    This would include file changes and change it to the new commit message.
  15. PUSH git push -- force Push changes from local repository

    to remote removing commits that are on the remote that do not exist on the local
  16. PUSH git push -- force-with-lease Push changes from local repository

    to remote removing your commits that are on the remote that do not exist on the local, but failing if there are commits by others
  17. NEW IN GIT 2.23 git restore <file> Discard changes made

    to the file * This is experimental and may change
  18. STASH git stash pop Apply changes from the top item

    in the stash list to the current branch
  19. MERGE CONFLICTS A merge conflict occurs when git is unable

    to automatically resolve the difference in changes between two or more commits.
  20. REBASE git rebase <branch> Apply commits from the current branch

    to follow the commits of the specified local branch
  21. REBASE git rebase -i <sha> Opens in interactive window with

    all commits from the specified to the most recent
  22. SQUASH git merge --squash <branch> Convert the commits of a

    specified branch into a single commit and merge it into the current branch