Githubz中特殊的命令Git-Specific Commands

刚开始接触Github,开始学习怎么用。整理一些Git的命令:

Since Git was designed with a big project like Linux in mind, there are a lot of Git commands. However, to use the basics of Git, you’ll only need to know a few terms. They all begin the same way, with the word “git.”



git init: Initializes a new Git repository. Until you run this command inside a repository or directory, it’s just a regular folder. Only after you input this does it accept further Git commands.

初始化一个新的Git存储。直到你在存储目录下用这个命令,就是一个常规的文件夹。只有你输入这个,会接受更多的git命令。


git config: Short for “configure,” this is most useful when you’re setting up Git for the first time.

在第一次设置Git的时候非常有用。


git help: Forgot a command? Type this into the command line to bring up the 21 most common git commands. You can also be more specific and type “git help init” or another term to figure out how to use and configure a specific git command.

忘记命令,可以用这个调出21个最有用的git命令。


git status: Check the status of your repository. See which files are inside it, which changes still need to be committed, and which branch of the repository you’re currently working on.

检查存储状态。看有哪些文件在里面,看看有哪些改变需要被委派,看看你现在用的有哪些存储集群。


git add: This does not add new files to your repository. Instead, it brings new files to Git’s attention. After you add files, they’re included in Git’s “snapshots” of the repository.

在Git中添加新的文件。


git commit: Git’s most important command. After you make any sort of change, you input this in order to take a “snapshot” of the repository. Usually it goes git commit -m “Message here.” The -m indicates that the following section of the command should be read as a message.

非常重要的命令,当你改变这些时,你输入这个,可以可以对存储状态进行“快照”。-m表明 如下命令章节应该作为信息来读取。


git branch: Working with multiple collaborators and want to make changes on your own? This command will let you build a new branch, or timeline of commits, of changes and file additions that are completely your own. Your title goes after the command. If you wanted a new branch called “cats,” you’d type git branch cats.

多方合作,你自己像有些改变,这条命令可以使你建立一个新的分支,或是执行的时间点,改变,文件附件。如果你想要一个新的分支叫猫,你要输入git branch cats。


git checkout: Literally allows you to “check out” a repository that you are not currently inside. This is a navigational command that lets you move to the repository you want to check. You can use this command as git checkout master to look at the master branch, or git checkout cats to look at another branch.

检查各个分支的存储


git merge: When you’re done working on a branch, you can merge your changes back to the master branch, which is visible to all collaborators.  git merge cats would take all the changes you made to the “cats” branch and add them to the master.

融合


git push: If you’re working on your local computer, and want your commits to be visible online on GitHub as well, you “push” the changes up to GitHub with this command.

发布


git pull: If you’re working on your local computer and want the most up-to-date version of your repository to work with, you “pull” the changes down from GitHub with this command.

更新


You could stop there and GitHub would work fine. But if you want to work on your project on your local computer, you need to have Git installed. In fact, GitHub won’t work on your local computer if you don’t install Git. Install Git for Windows, Mac or Linux as needed.

如果你想要在自己的电脑上开始这项工程,你必须先在Git上初始化,否则GitHub不会工作。


http://git-scm.com/, where you download Git.


git config --global user.name "Your Name Here"
git config --global user.email "your_email@youremail.com"


That’s all you need to do to get started using Git on your computer. However, since you did set up a GitHub.com account, it’s likely you don’t just want to manage your project locally, but also online. If you want you can also set up Git so it doesn’t ask you to log in to your GitHub.com account every time you want to talk to it. For the purposes of this tutorial, it isn’t a big deal since we’ll only be talking to it once. The full tutorial to do this, however, is  located on GitHub .


Creating Your Online Repository


Creating Your Local Repository


mkdir ~/MyProject

mkdir is short for make directory. It’s not actually a Git command, but a general navigational command from the time before visual computer interfaces. The ~/ ensures that we’re building the repository at the top level of your computer’s file structure, instead of stuck inside some other directory that would be hard to find later. Actually, if you type ~/ into your browser window, it’ll bring up your local computer’s top level directory. For me, using Chrome on a Mac, it displays my Users folder.

Also, notice that I called it MyProject, the very same name I called my GitHub repository that we made earlier. Keep your name consistent, too.

Next, type:

cd ~/MyProject

cd stands for change directory, and it’s also a navigational command. We just made a directory, and now we want to switch over to that directory and go inside it. Once we type this command, we are transported inside MyProject.

Now we’re finally using a Git command. For your next line, type:

git init

You know you’re using a Git command because it always begins with git.init stands for “initialize.” Remember how the previous two commands we typed were general command-line terms? When we type this code in, it tells the computer to recognize this directory as a local Git repository. If you open up the folder, it won’t look any different, because this new Git directory is a hidden file inside the dedicated repository.


原文章出自http://readwrite.com/2013/09/30/understanding-github-a-journey-for-beginners-part-1/,对其进行有用节选,并翻译,画出重点。





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值