A
A
Alex_872017-07-12 14:23:22
git
Alex_87, 2017-07-12 14:23:22

How to remove a commit in git?

Hello! I'm just starting to learn git, so I'm a little confused, please tell me about a few questions ...
1) When you write the git commit -m "Message" command, is it only entered in the local repository, or is it immediately thrown to the remote one, to github? I just don't know how to delete commits, so I'm asking before the experiment) Hence the second question....
2) How can I delete unnecessary commits from both the local and remote repository?
3) What files should be added to the repository in general? Let's say that I have files such as gulpfile.js, package.json Do I need to add them to a commit once, and add only those files that change to the next ones? Will these be automatically taken from the first commit?
PS And if you imagine a situation where local commits are made. Nothing remotely staged... look at the commits and remove a local commit of your choice, maybe?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
piatachki, 2017-07-12
@piatachki

I myself am not a great specialist, but I see the answer as follows:
1. There are two commands - commit and push. The first one adds a commit to the local checkout (I don't know how it's called in Russian terminology). The second sends a basket of commits to remote repository
2. Commits are not deleted, but they can be rolled back - grow a branch from any previous commit. The operation is called not (as rightly noted in the comment to the answer) pick cherry, but somehow differently.
3. The general rule of good form, as I understand it, is to send only changing files to the repository. That is, for example, code, but not third-party libraries. Regarding the specific segmentation of changed files - git-clients themselves determine which files have changed within the commit and synchronize them selectively.

S
Saboteur, 2017-07-12
@saboteur_kiev

git commit - this is to a local
git push - already ready commits are thrown into remote
commits are not deleted, you can simply roll back your branch to the last good commit and continue to commit new correct commits. Lost (headless) commits can be deleted automatically by the garbage collector. Usually in a month.
You add to the commit what has changed since the last commit. Use git status more often

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question