Git Notes


Git 學習筆記。


Git Config

update personal information in: ~/.gitconfig, as below:

1
2
3
[user]
name = Rick Hwang
email = rick_kyhwang@hotmail.com

Clone repository from bitbucket or github

  1. git clone https://${bitbucket or github}/${account}/${repository}.git
  2. put a file README.md to gtcafe folder.
  3. git status shows git status, you will see the unstaged files in red.
  4. git add README.md, check git status again, README.md will be staged status.
  5. git commit -m 'comment' commit the file to local
  6. repeat step (2) - (5)

push the data to remote

  1. git remote -v: list remote repository
  2. git remote add origin https://bitbucket.org/rick_kyhwang/gtcafe.git
  3. list remote repository again
  4. git push origin master: push to master branch in origin

    origin is an alias name, you can specify the suitable one to recoginze.

Create a branch

  1. git branch -v shows the branch list
  2. git branch v0.2.x creates a branch named v0.2.x
  3. git checkout v0.2.x switch branch to v0.2.x
  4. update one of files, commit
  5. create a new file, commit, and push: git push orogin v0.2.x
  6. switch to master branch git checkout master, check the new file if existing

Create a tag

  1. git tag shows tag list
  2. git tag -a v0.1.x create a tag named v0.1.x in local
  3. git push orogin v0.1.x push local tag to remote
1
2
3
4
5
# Sync the branch
git push <remote> <branch>

## How to reset a file which was modified?
git checkout -- {filename}

Relevant Documents

Reference


Comments