社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
git init
git add readme.txt
git add .
git commit -m "wrote a readme file" (-m "这里是提交说明")
git status
git diff readme.txt
git log
或者更加清晰的
git log --pretty=oneline
git reset --hard HEAD^
当我们用HEAD时,表示最新的版本。
git reflog
git checkout -- yourefile
git checkout your-branch
1.从本地 rm test.txt
2.从版本库 $ git rm test.txt
3.$ git commit -m “remove test.txt”
4.删除错了需要回滚:git checkout – test.txt
关联后,使用命令git push -u origin master第一次推送master分支的所有内容;
每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改;
$ git clone http:xxx.com
git checkout -b dev
git checkout命令加上-b参数表示创建并切换,相当于以下两条命令:
$ git branch dev
$ git checkout dev
查看分支
$ git branch
合并其他分支的内容到当前分支
git merge dev
git branch -d dev
Git还提供了一个stash功能,可以把当前工作现场“储藏”起来,等以后恢复现场后继续工作:
$ git stash
git stash list命令看看
一是用git stash apply恢复,但是恢复后,stash内容并不删除,你需要用git stash drop来删除;
另一种方式是用git stash pop,恢复的同时把stash内容也删了:
查看远程库的信息
git remote
origin
查看详细信息
git remote -v
origin git@github.com:xxx/learngit.git (fetch)
origin git@github.com:xxx/learngit.git (push)
/storage/cache/*
!/storage/cache/index.html
git pull https://username:password@xxx.com/project_name.git
(username不用邮箱的@部分)
方式一:修改远程仓库地址
【git remote set-url origin URL】 更换远程仓库地址,URL为新地址。
方式二:先删除远程仓库地址,然后再添加
【git remote rm origin】 删除现有远程仓库
【git remote add origin https://xxx.you-url.com】添加新远程仓库
git archive -o ./export.zip 7b9cead0f411ce42637f7633cfbb7c9078d3202e $(git diff --name-only a0ca27310aab94205d18c3415bd40b9821de2650 7b9cead0f411ce42637f7633cfbb7c9078d3202e)
a0ca27310aab94205d18c3415bd40b9821de2650 开始 commitId
7b9cead0f411ce42637f7633cfbb7c9078d3202e 结束 commitId
git config --global core.autocrlf false
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!