git-commit

Skip past (full) staging area and commit file or patch directly?

烈酒焚心 提交于 2019-12-11 03:36:08
问题 Imagine this scenario: you're working on a feature that requires touching lots of files, and you've got a lot of things staged, and a lot of things not staged (like debugging code, temporary comments for yourself to remember to do/undo certain things and not forget to add bits that you didn't yet have time to add), and then you see a simple one-line change that you must make, but which belongs in its own commit. Is there any way to simply commit that without pulling everything out of the

Commit and push changes after going back to a particular revision in the repository?

谁都会走 提交于 2019-12-11 02:18:32
问题 We need to go back in time to a particular commit. Some accidental changes were made to master. Attempts to revert it dug too deep, so master is in a bad state. We now want master to go back to 66ada4cc61d62afc. According to git revert back to certain commit: $ git reset --hard 66ada4cc61d62afc HEAD is now at 66ada4c Updated documentation Then, trying to commit it: $ git add *.h *.cpp $ git commit -m "Go back to Commit 66ada4cc61d62afc" On branch master Your branch is behind 'origin/master'

Importing commit history from Bitbucket to Github

。_饼干妹妹 提交于 2019-12-11 00:27:16
问题 I wanted to import a project from Bitbucket to Github (both public repos). However at some point in time (not the commit pointed by HEAD) some very large files were used which made the above process to fail. So I just pushed the plain source code to gh. I would like however to be able to have the project's commit history to gh. Is there a way to do this? 来源: https://stackoverflow.com/questions/39594572/importing-commit-history-from-bitbucket-to-github

How to commit a single staged file?

断了今生、忘了曾经 提交于 2019-12-10 18:01:55
问题 I have staged two files file1.js and file2.js but I only want to commit file2.js . How can I do this? 回答1: Simplest solution: unstage the other (git status tells you how, git reset ). 回答2: No need to unstage file1.js (assuming you want to keep the changes in this file staged for the next commit), just enter git commit file2.js to only commit the changes recorded in file2.js . 回答3: What I did was git reset file1.js to unstage it. Then I commited file2.js like i normally do. 回答4: Reset/Unstage

Why are folders left in my local git working directory after commit and checkout

狂风中的少年 提交于 2019-12-10 13:49:50
问题 I have created a folder containing files in my local working git structure. I created a new branch with git checkout -b and used git add . and git commit -m "..." to add those files to my local branch. But, when I do git checkout master the folder I created and committed is still there. Why? I thought git commit would put the folder and its contents into my local branch, switching it out when I checkout master. 回答1: If you add previously untracked files to a new branch, and then you checkout

Git, read latest commit message when committing

老子叫甜甜 提交于 2019-12-10 13:24:35
问题 When I am committing, this text jumps up: Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. On branch master Your branch is ahead of 'origin/master' by 2 commits. Changes to be committed: new file: modules/new_file.txt What I want is to let this informative text also show me the message of my last commit, without me needing to go through git log , git show or anything similar. E.g. (...) Changes to be committed:

Why can I not commit? (Your branch is up-to-date with 'origin/master', no changes added to commit)

杀马特。学长 韩版系。学妹 提交于 2019-12-10 12:55:51
问题 I have been having some trouble committing a file to GitHub. I can make it to git add, but soon as I try $ git commit -m 'my message' I get an error, not allowing me to complete the process of adding a file. $ git add HelloWorld.md $ git commit -m 'Hello world' I get the following answer (deleted: README.md & .DS_Store are in red): On branch master Your branch is up-to-date with 'origin/master'. Changes not staged for commit: deleted: README.md Untracked files: .DS_Store no changes added to

How to remove history of deleted git subtree folder?

家住魔仙堡 提交于 2019-12-09 18:48:49
问题 I added a git repository using git-subtree. The problem is that I did a hard reset back to before the repository was added with git-subtree. Now the commit history is still in the repository but it's disconnected from master. Any idea how to remove it? I tried git rm --cached with no luck. 回答1: To remove right away commits that are already unreachable, which would be the case of your subtree commits, you can use the following commands: git reflog expire --all --expire-unreachable=0 git repack

How do I use the --work-tree option with git? I keep getting an error

∥☆過路亽.° 提交于 2019-12-09 16:14:12
问题 I have a normal repo where there is a working tree and a .git folder in the same directory as the working tree. I'm trying to run a git command from outside this location with the command git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo pull /some/other/repo master but I keep getting the error fatal: /usr/libexec/git-core/git-pull cannot be used without a working tree. . What am I doing wrong? 回答1: This is a bug in earlier versions of Git. This problem should go away once you

How do I add the src directory instead of the individual files?

若如初见. 提交于 2019-12-08 12:22:58
问题 I've created a directory called 'src' which contain the files 'level.txt' and 'notes.txt': Remys:git-practice Remyce$ cd src Remys:src Remyce$ ls level.txt notes.txt How do I add the src directory instead of the individual files? It keeps coming up with: Remys:src Remyce$ add src -bash: add: command not found I also need to commit the files to the repo. 回答1: Go back to your git-practice directory, then git add src git status git commit -m "created a directory called which contain the files"