- git init
- git status
- git add readme.txt
- git add --all Adds all new or modified files
- git commit -m"message"
- git add ‘*.txt‘ Add all txt file in the whole project
- git remote add originName https://github.com/try-git/try_git.git :告诉git,新增一个类似于bookmark的信息,以便后面push分享
- git remote -v 列出所有已知的remote列表
- git push -u originName master (
-u
tells Git to remember the parameters, so that next time we can simply rungit push
and Git will know what to do.)。push到remote的repository以便分享给他人(通过pull操作) - git pull originName master
- git diff show unstaged differences since last commit
- git diff HEAD
- git add octofamily/octodog.txt
- git diff --staged view staged differences: staged files are files we have told git that are ready to be committed
- git reset octofamily/octodog.txt cancel the staged octodog.txt file
- git reset HEAD LICENSE Unstage staged file for LICENSE file
- git checkout -- octocat.txt retrieve latest octocat.txt and lost changes
- git branch clean_up create one branch to work on
- git checkout clean_up switch to the clean_up branch
- git rm ‘*.txt‘
- git commit -m "Remove all the cats"
- git checkout master switching to master branch
- git merge clean_up merge master with clean_up branch modifications
- git branch -d clean_up delete the clean_up branch after finished work on that branch
- git push push all the work we finished to github
- git log
- git commit -a -m "modify readme" 将add to stage和commit change合二为一(add changes from all tracked files: DOES NOT ADD NEW FILE(untracked)!!)
- git reset --soft HEAD^将最后的一个commit rollback到staging area,再做修正后,比如增加新的文件,修改已有文件,之后再做commit动作
- git add todo.txt; git commit --amend -m "forget the todo.txt in last commit, so amend it here"
- git reset --hard HEAD^;git reset --hard HEAD^^ 撤销掉最后一个/两个commit
常见workflow场景:
Jane创建一个文件,增加该文件到staging area,提交commit变更;
Jane修改了readme.txt文件并且增加了license文件,增加这些修改到staging area,提交变更集
Hosted GIT repository: Github, BitBucket;
Selft Managed: Gitosis, Gitorious
时间: 2024-10-10 03:43:07