git-commit

Git commit opens blank text file, for what?

大憨熊 提交于 2019-12-18 09:57:07
问题 In all the Git tutorials I've read they say that you can do: git init git add . git commit When I do that I get a big text file opened up. None of the tutorials seem to address this, so I don't know what to do with the file or what to put in it if anything. 回答1: You're meant to put the commit message in this text file, then save and quit. You can change the default text editor that git uses with this command: git config --global core.editor "nano" You have to change nano to whatever command

git add . vs git commit -a

走远了吗. 提交于 2019-12-17 23:29:08
问题 What's the difference between: git add . git commit -a Should I be doing both, or is that redundant? 回答1: git commit -a means almost[*] the same thing as git add -u && git commit . It's not the same as git add . as this would add untracked files that aren't being ignored, git add -u only stages changes (including deletions) to already tracked files. [*] There's a subtle difference if you're not at the root directory of your repository. git add -u stages updates to files in the current

How to get the last commit ID of a remote repo using curl-like command?

我是研究僧i 提交于 2019-12-17 23:03:02
问题 I want to get the last commit ID of the remote git repo. The command git rev-parse HEAD works for a locally-cloned git repo, but I want to get it from the original GIT repo by a CURL command or so. Eg: I want to get the last commit ID of the git URL https://git.appfactorypreview.wso2.com/history/apiapp.git/. How? 回答1: try this command git log --format="%H" -n 1 回答2: I think what you want is this: git ls-remote $URL HEAD If HEAD doesn't exist in the remote repository, then you likely want: git

How to review a specific commit on Git

你。 提交于 2019-12-17 19:24:33
问题 I sent a commit (named "A commit") to review (Gerrit) using git review command. Now, I make a new commit (named "B commit") and I want to send it to review as well, but I don't want to re-send the "A commit". There is no dependencies each other. How to send a review to gerrit for a specific commit?. UPDATE : $ git add --all $ git status # On branch delete_role # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: path/to/file.ext $ git status # On branch

How to remove the first commit in git?

冷暖自知 提交于 2019-12-17 17:24:40
问题 I am curious about how to remove the first commit in git. What is the revision before committing any thing? Does this revision have a name or tag? 回答1: For me, the most secure way is to use the update-ref command: git update-ref -d HEAD It will delete the named reference HEAD , so it will reset (softly, you will not lose your work) all your commits of your current branch . If what you want is to merge the first commit with the second one, you can use the rebase command: git rebase -i --root A

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch

二次信任 提交于 2019-12-17 17:18:03
问题 I am using Git. I did a pull from a remote repo and got an error message: "please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch." I try to type a message and press Enter but nothing happens. How do I tell Git/terminal I am done typing in my message? I am using terminal on OS X. 回答1: It's not a Git error message, it's the editor as git uses your default editor. To solve this: press "i" write your merge message

Fix GitLab error: “you are not allowed to push code to protected branches on this project”?

谁说我不能喝 提交于 2019-12-17 08:02:26
问题 I have a problem when I push my codes to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it? Error message: error: You are not allowed to push code to protected branches on this project. ... error: failed to push some refs to ... 回答1: there's no problem - everything works as expected. In GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches

What is a Git commit ID?

妖精的绣舞 提交于 2019-12-17 07:30:45
问题 How are the Git commit IDs generated to uniquely identify the commits? Example: 521747298a3790fde1710f3aa2d03b55020575aa How does it work? Are they only unique for each project? Or for the Git repositories globally? 回答1: A Git commit ID is a SHA-1 hash of every important thing about the commit. I'm not going to list them all, but here's the important ones... The content, all of it, not just the diff. Commit date. Committer's name and email address. Log message. The ID of the previous commit(s

git - Find commit where file was added

假如想象 提交于 2019-12-17 04:12:29
问题 Say I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added. After reading the answers and my own tinkering, this works for me git log --follow --diff-filter=A --find-renames=40% foo.js 回答1: Here's simpler, "pure Git" way to do it, with no pipeline needed: git log --diff-filter=A -- foo.js Check the documentation. You can do the same thing for Deleted, Modified, etc. https://git-scm.com/docs/git-log#Documentation/git-log

How to reference the initial commit?

夙愿已清 提交于 2019-12-17 03:28:33
问题 I've got a script that needs to reference the initial commit in a repository. git has the special reference HEAD , but doesn't have the corresponding TAIL . I cannot find anything in git help rev-parse that would seem to help me. Here's what I'd like to do: git show TAIL Here's one option I have: git show `git log --reverse | if read a commit ; then echo $commit ; fi` That's pretty hacky and depends on the output of git log not changing. Right now I just tag the initial commit and use that as