我在GitHub上有一个存储库,我想用从中提取的文件夹中所做的更改来更新它。
对于一个新的Git用户来说,在使用cd目录
之后应该执行哪些步骤,不要使用术语或缩写?
包括如何跟踪对任何文件所做的本地更改,然后如何将这些更改和更新发送回远程存储库。
最简单的流程是这样的:
# clone the repository (from github, for example)
git clone git@github.com:username/reponame.git
cd reponame
# edit some files
# add them to the index
git add file1.txt
git add file2.gif
# review your changes
git status
# commit the changes
git commit -m "Decription of my change"
# push them back to the remote repository
git push origin master
我猜你是一个独立工作的人,所以这很简单。
1) 通过SSH使用"git clone"完成。Github网站会提供克隆URL。
2) 只需在本地工作,这就是分布式版本控制系统的用途:-) 然后"git commit"你所开发的内容。
3) 你需要将你的分支"git push"到Github上。其他人就可以获取它了。
这些都是基础知识,当你对这个最简单的工作流程感到自信时,你可以学习很多适合你编码实践的东西,重写你的历史和很多好玩的Git技巧。
并且你将学会如何与其他人合作、合并和变基。
首先,你需要进入代码库:
cd My-Repository
您需要将所有想要提交的文件添加到代码库中:
git add my-code
git commit -m "Commit-Message"
然后,您将更改推送到Github(请确保通过SSH或HTTPS克隆它)。在使用分支时,您必须将“master”替换为正确的分支名称。
git push origin master
以下是您所需内容的简要概述:
Create a local version of the remote repository on my computer:
git clone <remote-url>
Start making and tracking changes to the local copy:
# Add or modify some files.
# Then add them to Git's staging area:
git add <file1> <file2> <etc>
# Commit the changes
git clone -m "Your commit message"
When you're done making changes, push them back to the remote repository.
git push origin <branch>
When you push to the remote repository, your changes may be rejected because there are new commits on the remote that you need to merge your work with, in which case you can
git fetch origin
git merge origin/branch
# Or
git rebase origin/branch
to synchronize your local work with the new changes, then try pushing again. Avoid rebasing commits that are already shared with other people though, because it will force them to resynchronize their work with the rewritten commits (if your team is comfortable with this, then this is feasible).
我上面提到的只是一个简短的总结。我甚至没有讲解如何解决合并冲突。
如果你真的想熟练掌握Git,我仍然强烈建议你阅读免费在线的Pro Git书籍,特别是第1-3章和第6-6.5章。甚至有iPad、Kindle和PDF版本可供免费下载。