git
  KRsXEGSB49bk 2023年11月19日 19 0

1. gitignore文件不起作用的解决方案:

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

2. 拉取线上特定的分支(如:克隆dev分支的代码):

git clone -b dev git-url
// 在本地创建分支dev并切换到该分支
git checkout -b dev(本地分支名称) origin/dev(远程分支名称)

注:
①. -b表示要从分支下载.
②. dev是具体某个分支的名称.

3. 初始化本地已有的项目上传到新仓库:

# 把远端仓库中的代码拉到本地进得合并一下:
git pull --rebase origin master

注:
①. rebase操作不会生成新的节点,是将两个分支融合成一个线性的提交.

(1). 初始化已有的项目:

$ git init
$ git add .
$ git commit -m "push current files"
// 将本地仓库与远程仓库关联起来
$ git remote add origin git@github.com:xxx.git
// pull远程仓库的内容、更新本地仓库.
// –allow-unrelated-histories会忽略本地仓库和远程仓库的无关性,强行合并
$ git pull origin master --allow-unrelated-histories
// 把本地仓库的内容push到远程仓库:
$ git push -u origin master

4. git初始化:

①. Existing folder:
    git init
    git remote add origin git@xxxxxx/gin-data.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master

②. Existing Git repository:
    git remote remove origin
    git remote add origin git@xxxxx/gin-data.git
    git push -u origin --all
    git push -u origin --tags

4. 去掉本地修改:

git reset -–hard

5. git报错:

hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.

// 解决办法:
$ git config pull.ff false
$ git config --global pull.rebase false
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月19日 0

暂无评论

推荐阅读
  pfl0iGEgXbv6   2023年11月19日   20   0   0 git用户名bc
  dooxi4Nu3rdc   2023年11月19日   37   0   0 重启git
  KRsXEGSB49bk   2023年11月22日   23   0   0 本地缓存git取代码
  ojFX2cbvFbdn   2023年11月19日   24   0   0 gitrpm包ci
  17eFBvSPo0pz   2023年11月19日   19   0   0 git
  Ogzy9ibNXM9w   2023年11月19日   19   0   0 gitnginxbc
  17eFBvSPo0pz   2023年11月19日   22   0   0 gitgit仓库
  9JCEeX0Eg8g4   2023年11月22日   22   0   0 远程仓库命令行推送
  KRsXEGSB49bk   2023年11月22日   18   0   0 git推送取代码
  L83A5jZvvg3Q   2023年11月19日   25   0   0 vim初始化物理内存