Git学习笔记-Basic Git

1.Three main sections of Git: the git directory, the working directory, and the staging area.

Git directory: where git stores the metadata and object database (most important).

Working directory: a single checkout of one version of the project. Pulled out of the Git database and plcaed on disk for use or modify.

Staging area:A simple file contained in the Git directory which stores information about what will ao into your next commit.

2.State of files: untracked -> unmodified -> modified -> staged -> commited

3.Three git config files: /etc/git config(git config --system); ~/.gitconfig(git config --global); .git/config.

4.Check git settings: git config --list.

5.Initializing a Repository: git init; git clone git://....(url).

6.Check the state of git: git status.

7.Tracking files: Git will not track new files automatically until you asked to do so. To begin tracking files, run this: git add file.

8.Staging files: run git add. If you modify a file after run git add, you have to run git add again to stage the latest version of the file.

9.Ignore files: Setting up a .gitignore file if you don't want some filed commited in Git repository.

    Rule of patterns for .gitignore:

  • Blank lines or lines starting whith # are ignored.
  • Standard glob patterns work.
  • End patterns with a forward slash (/) to specif a directory.
  • Negate a pattern by starting it with an exclamation point (!).

10.To see what you've changed but not staged, type git diff. To see what you've staged that will go into your next commit,type git diff --staged.

11.Commit files:git coomit -m "message". Skipping the staging Area to commit: git -a -m "message".

12.Rmoving files: git rm command remove file from staging area and working directory, then commit. If simply remove the file from working directory, it shows up under the "Changed but not updated" and then you should commit again.

13.Moving files: git mv file_from file_to is equivalent to mv file_from file_to, git rm file_from, git add file_to.

14:Viewing the Commit History: git log. gitk.

15.Undo Things:

  • Change Last Commit: git commit --amend which overwrites previous commit.
  • Unstaging a Staged file:git reset HEAD file.
  • Unmodifying a Modified File:git checkout -- file.

16.Working whith Remotes:see remotes:git remote -v.

17.Adding Remote Repositories: git remote add [short name] [url].

18.Fetching and Pulling from Remotes: git fetch/pull [remote-name], git push [remote-name] [branch name].

19.Removing and Renaming Remotes: git remote rename [original] [new]. git remote rm [remote-name].

20.Git Aliases: git config --global alias.[alias] 'original comment'. eg.git config --global alias.unstage 'reset HEAD --'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值