简体   繁体   English

多次添加和删除后git push

[英]git push after multiple add and remove

A few days ago I create a repository with an android project that I have been working on. 几天前,我创建了一个我正在研究的android项目的存储库。 Since then I have deleted a number of files and have added a number of others. 从那时起,我删除了许多文件,并添加了许多其他文件。 Now I want to push my new changes to github. 现在我想将我的新更改推送到github。 How do I do that? 我怎么做? What are the commands to issue? 发出什么命令? I know I have o commit and then push to master. 我知道我已经提交,然后推动掌握。 But how do I tell git that I have added and deleted a number of files? 但是,如何告诉git我添加并删除了许多文件? Normally I just do git add . 通常我只是做git add . since normally I am adding stuff. 因为通常我会添加东西。 But this time I have x new files and y deleted files. 但这次我有x个新文件和y删除文件。

To push my changes I do: 1. git add . 为了推动我的改变,我做了:1。git add。 2. git commit -m "write my comments for change" 3. git push origin<< provide my credentials 2. git commit -m“写我的评论以进行更改”3. git push origin <<提供我的凭据

You can use git add --all . 你可以使用git add --all . to record all changes, including deletions. 记录所有更改,包括删除。 From the man page: 从手册页:

-A -一种
--all - 所有
Like -u, but match against files in the working tree in addition to the index. 与-u类似,但除了索引之外还匹配工作树中的文件。 That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree. 这意味着它将找到新文件以及暂存已修改的内容并删除不再在工作树中的文件。

If you want more granular control, use git rm <filespec> to remove files from the index. 如果您想要更精细的控制,请使用git rm <filespec>从索引中删除文件。

After that, commit and push as usual. 之后,像往常一样commitpush

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM