dch*_*tri 54 git github git-push
是否可以删除存储库中的所有文件并仅使用我本地计算机中的文件进行更新?原因是,在我的github中有一些不需要的文件,所以我想删除这些文件.我没有逐个删除文件,而是想看看是否可以删除我的git repo中的所有文件并仅使用本地机器中的文件进行更新/推送.希望清楚.谢谢.
pas*_*cal 54
你可以这样做:
cd /tmp
git clone /your/local/rep # make a temp copy
cd rep
git rm -r * # delete everything
cp -r /your/local/rep/* . # get only the files you want
git add * # add them again
git status # everything but those copied will be removed
git commit -a -m 'deleting stuff'
cd /your/local/rep
git pull /tmp/rep # now everything else has been removed
Run Code Online (Sandbox Code Playgroud)
可能有一个oneliner ...
tab*_*bim 35
首先,使用以下命令从Git存储库中删除所有文件: git rm -r *
之后你应该提交:使用 git commit -m "your comment"
之后你推动使用:( git push
那是更新原始存储库)
使用以下方式验证您的状态 git status
之后,您可以复制本地Git文件夹中的所有本地文件,然后使用以下命令将它们添加到Git存储库: git add -A
你提交(git commit -m "your comment"
并推送(git push
)
删除存储库中的所有元素:
$ git rm -r *
Run Code Online (Sandbox Code Playgroud)
然后:
$ git commit -m 'Delete all the stuff'
Run Code Online (Sandbox Code Playgroud)
首先,使用cd(更改目录)命令导航到您的文件夹。然后使用以下命令确保您位于要工作的正确 git 分支中
git branch
Run Code Online (Sandbox Code Playgroud)
如果你想删除整个文件。你可以使用同样的方法
git rm -r .
用于删除单个文件,
git rm file1.txt
( file1.txt - 文件名)
对于删除文件夹,
git rm -r foldername
删除文件或文件夹后,您应该提交它:
git commit -m "your comment"
Run Code Online (Sandbox Code Playgroud)
然后你可以推送分支:
git push
// for example,
git push origin develop
Run Code Online (Sandbox Code Playgroud)
(它将更新原始存储库)
这个过程很简单,并且遵循与任何 git commit 相同的流程。
git pull
)git commit -m "nuke and start again"
git push
归档时间: |
|
查看次数: |
145909 次 |
最近记录: |