git and github simple tutorial

git and github simple tutorial

First, create a warehouse

  1. Click newAdd to enter the warehouse page

  1. The warehouse will create some simple settings

  1. Finally, click create repositoryon it.

  1. With this we have created a warehouse.

Second, the use git clone, cloned into the local repository

Created on github a warehouse, how it clones (clone) to a local do? This time we need to use git to manage and synchronize. First you need to go to the official website to download git git , then install it. Next we use the git clone command to a local warehouse.

  1. Using SSH

  1. Create a workspace in the local git

  1. Git into the workspace, open a command window git

  1. Use git clonecommand on the remote repository cloned into local workspace

Format:git clone 刚刚复制的SSH口令

This time we re-open the area to see if it came cloning:

We can see this folder hidden files, see the following steps:


If we want to modify or add a local warehouse of some files, how to update it to the far end? It needs to go through the following three steps:

  1. Use git add command to commit changes to the work area to the staging area
  2. Use git commit command to submit modifications to the master branch from scratch
  3. Use git push command to modify the master branch pushed from the distal end

Third, use git add, modify submitted to the staging area (index or stage)

  1. First, we need to make some changes to git work area, such as creating a new filefirst.txt

  1. Use the commandgit add 文件名

  1. To which changes have been saved in the staging area, we can use the git statuscommand to view the current status

At the same time we can see user "git reset HEAD <file>..." to unstage, means that we can use this command git reset HEAD 文件名, just submit the withdrawal. There is no longer a demonstration, interested students can try.

Fourth, use git commit, commit your changes to the local master branch

  1. The command format is: git commit -m "对此次提交的简单说明", -min the mmean message.

  1. 再次使用git status查看当前状态

五、使用git push,将本地修改

  1. 使用git push命令就可以将本地master中的修改提交到远端master中去了。

  1. 这时候我们刷新github看看


到这,我们已经完成了git的一些基本操作,接下来我们补充一些比较常用的其它git命令。

查看操作git log,git show commit id

使用git log命令可以查看我们所有的commit日志

使用git show commit id命令可以查看一个commit的详细信息

回滚操作git reset commit id

在进行push之前我们可能会进行多次commit操作,有时候我们希望能够退回到某一次commit时的状态,这时我们可以使用git reset commit id命令。

但请注意,push完之后再reset是没用的,reset只对本地有效!

拉取操作git pull

有时候远端修改领先与我们的本地修改,因为一个仓库可能有多人同时在修改更新,如下图所示:

这时候我们就需要使用git pull命令来拉取远端的最新状态,同步到本地。


好的,这就是这篇文章的所有内容了,有问题欢迎留言。

Guess you like

Origin www.cnblogs.com/huwt/p/12202887.html
Recommended