Lab1 Using git

A. Intro to version control Systems

Version control systems can track the history of code revisions, from current state of the code all the way back until it was first tracked.

Git is one tool that allow us version control. Git has excellent documentation.

Git is ditributed version control system

  • As opppsite centralized version control system. This means that every developer’s computer stores the entire history(including all old versions) of the entire project!
  • We call the entire history of an entire project a “repository”
  • The repository is stored locally leads us to our ability to use Git locally on our own computers, even without an interet connection.

B. Local Repostitories

  • git init: tells the git version control system that we want to track the history of the current directory.
  • git add :add file to the list of files to track, and ready be commited
  • git commit -m"":stick cpoies of out tofu recipes into the repository -m command lets us add a message to the commit
  • git log : Lists all the panoramic photos we’ve ever taken
  • git status: Show you the current tracked and untracked files
  • git show : Looks at what is insde a paticular file
  • git checkout: Rearranges files back to how they looked in a given status
    • The right format to use git checkout : ****git checkout ######### file.txt

Undoing changes

  • Unstage a file that you haven’t yet committed:$ git reset HEAD [file]
  • Amend latest commit(Changing commit message or add forgotten files)This new amended commit will replace the previous commit:$git add [forgotten-file] $git commit -—amend
  • Revert a file to its state at the time of the most recent commit: $ git checkout —[file]

Rule of Thumb:

If you commit, you can always revert your code or change it. However, if you don’t commit, you won’t be able to get old version back.


Additional comman line

If you want to create a file: touch file.txt

Use vim to edit your file: vim file.txt i: start to edit shift + esc to stop edit :wq save and quit the file

If you want to delete your git repo: rm -f .git