简单的GIT命令序列 [英] Simple Sequence of GIT Commands

查看:311
本文介绍了简单的GIT命令序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读文档和googled有点,但没有真正简单的步骤,以能够提交您的本地更改到github。我编译了以下步骤,我只是想确保做正确的事情。如果我在本地更改文件foo.java:

I read the documentation and googled a good bit, but there is no real simple steps to be able to commit your local changes to github. I compiled the following steps and I just want to make sure am doing the right thing. If I changed a file foo.java locally:



  1. git status -s             //将显示foo.java已更改

  1. git status -s          //will show me that foo.java has changed

git add foo.java      //将其添加到我的本地仓库

git add foo.java     //will add it to my local repo

git commit -mmy changes      ; //提交到本地仓库

git commit -m "my changes"      //commit to the local repo

git tagv1.1       //创建标签

git tag "v1.1"       //create a tag

git push --tags        // finally,将本地提交移动到远程仓库新标签。这将提示您输入密码。如果没有在步骤4中设置标签,则只需

git push --tags        //finally, move the local commit to the remote repo with the new tag. this will prompt for your password. if no tag is set as in step 4, then just




p>

git push


就足够了。是吗?

我只是想确保这些基本步骤为大多数用例是使用github所需要的。我是github的全新,这些步骤为我工作,但想确保我没有犯任何根本的错误。如果有任何缺少的步骤,请评论。再次,我关注最通用的日常使用(例如,我真的不关心分支,我会在需要的基础上学习)。先谢谢。

I am just trying to make sure that these basic steps for the most use cases is what is required to use github. I am brand new to github, and these steps are working for me, but want to make sure i am not making any fundamental mistake. Please comment if there are any missing steps. Again, am concerned about the most generic day-to-day use (like, am not really concerned about branches, etc. which I will learn on a need basis). Thank you in advance.

推荐答案

您的步骤很好。尽管如此,关于评论有点轻微:

Your steps are fine. To nit-pick slightly, though, about the comments:

关于步骤(2)和(3)的评论不是想想发生什么的最好方式,不相信。

The comments about step (2) and (3) are not the best way to think about what's happening, I don't believe.

2.git add foo.java     //will add it to my local repo
3.git commit -m "my changes"      //commit to the local repo

添加您的文件的步骤到本地存储库 git-commit 。这就是为什么它叫 commit ;您可以更改存储库。 git-add foo 添加 foo staging区强>到repo本身。

The step which "adds" your file to the local repository is git-commit. That's why it's called commit; you commit changes to the repository. git-add foo adds foo to the staging area, not to the repo itself.

您的 git 资料库有三个区域,工作 , , staging scm.com/book/en/Getting-Started-Git-Basicsrel =nofollow noreferrer> Pro Git book ):

Your git repository has three "areas", working, staging and repository, depicted here (image taken from the Pro Git book):

您可以在创意命名的工作目录。

You make changes and work in the creatively named "working directory".

进行一些更改后,您要准备提交。这是分段区发挥作用的地方。您阶段要提交的更改,当您对提交的内容感到满意时,就将暂存区域提交到存储库。 [注意:在 man 页面中,这个 staging区域主要指向 / code>]。

When you've made some changes, you want to prepare to make a commit. This is where the "staging area" comes into play. You "stage" the changes that you want to commit, and when you're happy with what the commit will look like, you commit the "staging area" to the "repository". [Note: in the man pages, this staging area is mostly referred to the index].

这让你有很大的灵活性。您可以从上次提交以后阶段性地进行所有更改,或者可以单独分阶段部署文件,也可以部署文件。您可以从暂存区域添加和删除文件,而不会丢失更改或清理存储库历史记录。这是 git add git rm 命令的作用;他们从工作目录添加到暂存区,但他们添加直接放入存储库。 (希望图像有助于使区分清楚)。

This allows you a lot of flexibility. You can stage all the changes since your last commit, or you can stage files individually, or you can stage parts of files. You can add and delete files from the staging area without losing changes or messing up the repositories history. That's what the git add and git rm commands do; they add from the working directory to the staging area, but they don't add directly into the repository. (Hopefully the image helps make the distinctions clear).

您的步骤很好。如果你想更多地了解分支,提交,操作提交和分支等,我建议阅读 Pro Git书 - 它有一堆漂亮的图片和语言很简单,我可以理解它;)

Your steps are fine. If you want to understand more about branching, commiting, manipulating commits and branches and whatnot, I'd recommend reading the Pro Git book - it's got a whole bunch of pretty pictures and language simple enough that I can understand it ;)

这篇关于简单的GIT命令序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆