Git bash 命令备忘


指定git用户   (tell git who you are)
git config --global user.email "you@example.com"
git config --global user.name "yourname@example.com"
初始化仓库并进行第一次的push

git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/MemoryOfStars/commandLines.git               #注意网址后要指明 .git  
git push -u origin master
从不同的local repository向同一个remote repository推代码(因为history不同,所以需要进行强制merge)
git pull origin master --allow-unrelated-histories  执行之后要重新add和commit  
git push -u origin master                           push到远程仓库  

管理已经绑定的远程仓库

检出仓库:$ git clone git://github.com/jquery/jquery.git  
查看远程仓库:$ git remote -v  
添加远程仓库:$ git remote add [name] [url]  
删除远程仓库:$ git remote
rm [name]

 

如果出现fatal:remote origin already exists(一般是因为这个代码本来就是从github上下载下来的)

git remote rm origin  先删除远程仓库再重新进行绑定  

从远程仓库更新代码到本地

git pull origin master     更新代码合并到本地(fetch+merge)
git fetch origin master   将远程仓库最新代码拉到本地,不进行合并

 



posted @ 2019-05-06 11:45  memory_of_stars  阅读(247)  评论(0编辑  收藏  举报