赞
踩
为所有本地存储库配置用户信息
设置要关联到提交事务的名称和邮箱
$ git config --global user.name "[name]"
$ git config --global user.email "[email address]"
启用命令行有用的着色
$ git config --global color.ui auto
启动一个新存储库或从现有 URL 获取一个
$ git init [project-name]
#Creates a new local repository with the specified name
$ git clone [url]
#Downloads a project and its entire version history
查看编辑并制作提交事务
$ git status
#Lists all new or modified files to be committed
$ git add [file]
#Snapshots the file in preparation for versioning
$ git reset [file]
#Unstages the file, but preserve its contents
$ git diff
#Shows file differences not yet staged
$ git diff --staged
#Shows file differences between staging and the last file version
$ git commit -m "[descriptive message]"
#Records file snapshots permanently in version history
命名一系列提交并结合已完成的工作
$ git branch
#Lists all local branches in the current repository
$ git branch [branch-name]
#Creates a new branch
$ git checkout [branch-name]
#Switches to the specified branch and updates the working directory
$ git merge [branch]
#Combines the specified branch’s history into the current branch
$ git branch -d [branch-name]
#Deletes the specified branch
重新定位和删除版本化文件
$ git rm [file]
#Deletes the file from the working directory and stages the deletion
$ git rm --cached [file]
#Removes the file from version control but preserves the file locally
$ git mv [file-original] [file-renamed]
#Changes the file name and prepares it for commit
注册存储库书签并交换版本历史记录
$ git fetch [bookmark]
#Downloads all history from the repository bookmark
$ git merge [bookmark]/[branch]
#Combines bookmark’s branch into current local branch
$ git push [alias] [branch]
#Uploads all local branch commits to GitHub
$ git pull
#Downloads bookmark history and incorporates changes
排除临时文件和路径
$ git ls-files --other --ignored --exclude-standard
#Lists all ignored files in this project
搁置和恢复不完整的更改
$ git stash
#Temporarily stores all modified tracked files
$ git stash list
#Lists all stashed changesets
$ git stash pop
#Restores the most recently stashed files
$ git stash drop
#Discards the most recently stashed changeset
浏览和检查项目文件的演变
$ git log
#Lists version history for the current branch
$ git log --follow [file]
#Lists version history for a file, including renames
$ git diff [first-branch]...[second-branch]
#Shows content differences between two branches
$ git show [commit]
#Outputs metadata and content changes of the specified commit
擦除错误并制作更换历史
$ git reset [commit]
#Undoes all commits after [commit], preserving changes locally
$ git reset --hard [commit]
#Discards all history and changes back to the specified commit
在克隆/下载的复制SSH里的git链接
在桌面右击,选择Git Bash Here,
使用命令git clone +复制的链接
克隆成功,可在桌面看到相关文件
在本地库上使用命令 git remote add把它和 gitee 的远程库关联,如下
git remote add origin git@gitee.com:username/test1.git
如果在使用命令 git remote add时报错:
git remote add origin git@gitee.com:username/test1.git
fatal: remote origin already exists.
说明本地库已经关联了一个名叫 origin的远程库,此时,可以先用git remote -v查看远程库信息:
git remote -v
origin git@gitee.com:username/test1.git (fetch)
origin git@gitee.com:username/test1.git (push)
可以删除已有的远程库
git remote rm origin
再关联远程库
git remote add origin git@gitee.com:username/test1.git
在本地添加test_pushFile.txt文件,
打开git,执行git的add、commit、push命令,即可将本地文件上传到远程仓库。进入工程文件,添加并提交事务:
push到远程仓库
刷新gitee网页,看见文件成功上传了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。