Tuesday, January 7, 2014

Git in a nutshell

The most basic CMDs you need in order to deal with Git and GitHub:

  git init      // initialize the git repository
  ls
  git status     //show what is going on!
  git add .     //add files from directory to the index
  git status
  git commit -m "add basic files"     // commit index to the head
  git status
  git remote add origin https://github.com/aselims/UCML.git      //the point connecting to GitHub
  git remote -v  
  git pull origin master   // retrieve data from server 1st step before uploading
  git add .
  git commit -m "modify readme2"
  git status
  git push origin master   // upload data


-- Terminology
§ master: This is what a branch is: it’s simply the hash of the last commit scribbled down in a file. It’s a clue, a starting point, sometimes called a tip because this represents the tip of the iceberg that is the entire history of the master branch.
~/mysite$ cat .git/refs/heads/master
0d0321f29f04f734e8d9873e34d9409fe115b496

And since you can have multiple branches in a repository, we should also remember which one we’re working on right now.
~/mysite$ cat .git/HEAD
ref: refs/heads/master

show the commit of 3bd54c
git checkout 3bd54c

- One good resource: http://rogerdudler.github.io/git-guide

No comments: