简单的为Android项目创建git仓库

一. git软件安装

    Ubuntu

sudo apt-get install git-core

二. 转到项目根目录

    略

三. 初始化

    配置身份        

git config --global user.name "yourName" | git config --global user.email "yourEmail"

   初始化仓库

git init

四. 添加提交本地代码

  添加单个文件(夹)或多个文件(夹)

git add [theFileOrDirYouWantToAdd]

  添加所有文件(夹)

git add .

  提交

git commit -m "Description Info for this commit"

五. 提交到远程仓库(Github)

    添加Github ssh秘钥

    略

    在Github创建空仓库

    略

    链接到远程仓库

git remote add origin [yourRemoteReposityURL]

    将本地分支链接到远程分支

    git branch --set-upstream-to=origin/master master

    pull

    git pull --allow-unrelated-histories origin master

    推送到远程仓库master分支 (第一次)

git push -u origin master

    推送到远程仓库master分支(非第一次)

git push orgin master

六. 其他命令

 

git
	
	git status								//view modified content
	
	the meaning of the colors
		red: not added
		green: added but not committed
	
	cancel the change which are not committed
		git checkout FilePathWithExtensionName

	view the versions which have been committed
		git log
	
	rollback
		git reset --hard HEAD[^...]                // the HEAD is stands for the current version. It stands for latest version if it's appended a '^'
		OR
		git reset --hard VersionID
	
	view history actions
		git reflog
	
	create a branch
		git branch BranchName

	create and check to the branch
		git checkout -b BranchName

	view branch
		git branch
	
	merge branch
		git merge BranchName

	linking with remote repo
		git remote add origin https://github.com/CQJTUWilliam/RemoteRepositoryName.git
	sync to remote repo
		git push -u origin master         // for the first time
		OR
		git push origin master

	remove the linking between local repo and remote repo
		git remote rm origin

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值