Github: 如何使用git.

使用github的步骤。

1:在github上创建repository:

2:在本地创建的文件夹下面使用命令:git init

3:添加文件:git add . (添加全部文件), 或着git add 文件名。

4:本地代码关联到github上。

git remote add origin https://github.com/jackymail/algorithm.git

5:提交项目到github上: git commit -m "first upload"

6:提交修改到github上:git push。

其它:

1:git merge <branch_name> merges. (比如说现在master branch的目录下面,希望合并从master 切出来的那个branch中修改的代码)。

2:git branch branchname 创建新的分支。

3:更新代码:git pull origin master。

应该类似于(svn的svn update.先更新一下代码)

4:上传代码:git push -u origin master。

查看改动历史:

5:git log --pretty

6:git log -p

7:查看本次修改的变动:git diff

8:单个文件修改后需要重新在 git add 一次。否者会出现“

Changes not staged for commit:”错误。

或着可以直接在后面增加文件名。

git commit -m "delete debug info" max_sum.c

9:git status 查看 当前的改动。例如增加或修改了文件。

10:添加空文件夹,现在暂时不知道怎么添加空文件夹,使用

git add * 或着 git add -A 都不能添加。所以使用的一个workaround是在每个文件夹下面先创建一个文件。

11:在git push 之前似乎一定要使用git commit 。否则会提示“everything up to data”.

8:needs merge

error: you need to resolve your current index first

问题的处理方法:

git reset --merge

12:切换分支: git checkout branch_name

13: 删除分支: git branch -D branch_name

14:git push --set-upstream origin master

ERROR: Permission to jackymail/Go.git denied to peterpainkiller.

fatal: Could not read from remote repository.

这个问题是出现在在新建的目录下面上传代码到github上。原因是在新建立的目录下面上传代码使用的是另一个目录的deploys key。 这个deploykey 在这个目录下面没有权限。解决方法是重新生成一个新的deploykey。添加到github中的sshkey中。

https://help.github.com/articles/error-permission-to-user-repo-denied-to-user-other-repo/

15: git push时遇到git上传一个巨大的core文件(应该是git add的时候不小心add上去的),导致push失败的解决办法:
https://help.github.com/articles/remove-sensitive-data/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤乐君阅读 6,180评论 3 11
  • 1.git的安装 1.1 在Windows上安装Git msysgit是Windows版的Git,从https:/...
    落魂灬阅读 12,723评论 4 54
  • 昨日,一员工合同到期,公司不续合同。于是乎,提着家伙上楼耍赖来了。 在他看来,公司不与他续合同,就是把他开除了。开...
    yhbmoren阅读 179评论 0 2
  • 乍暖还寒时,最难将息。 立春那晚,已和往日不同,冬被忽然就厚了重了,辗转几回平静不得,手脚和肩便不肯再乖乖顺服于衾...
    步绾阅读 1,970评论 97 90
  • 我是郑际童,2000.6.1,体重没过百,平胸,矮,丑,皮肤不好容易长痘痘。穷,没钱吃,没钱穿,没钱买化妆品,也没...
    羥羊阅读 252评论 0 3