Git

Download GIT

https://git-scm.com/downloads

Initiate/Clone

  • git init: initiate the current directory as a git repository
  • git clone https://github.com/SOMEONES/ACertainRepo.git: copy the repository of other’s to local

Add

  • git remote add origin https://github.com/yourname/YourRepo.git: create a remote named origin and establish the connection between local and the remote.

  • git add -A: make every file to be tracked and stage all changes (i.e., make all of them ready to be committed)

  • git add --all: Stage all changes; that is, make every modified files ready to be committed.

Commit and push

  • git commit -m "whatever message is OK": stage all changes of tracked files and commit; untracked files won’t be committed.

  • git push --set-upstream origin master(the first time) or git push (therein after)

Setting master as upstream means that from now on the target branch is set to be the master, and you can push and pull without specifying the target branch.

💩 Explain furthermore:

Set and sync with the upstream

Develop someone else’s project:

Source of this figure

📖Explain and Hints:

  • fetch retrieve the latest metadata info from remote; pull does that AND copy those changes from remote repository to local.
  • you may like to check the current remote repository and upstream by using git remote -v.

Handling file renames in Git

git mv css/iphone.css css/mobile.css See this.

Other useful commands

Cheat sheet

  • use git log to view the commit history
  • use git status to see the current status (list the staged and unstaged files that have beem modified, added, or deleted.)
Last modified January 15, 2022: MagTIP_installation (fcb9abb)