git-commit

GIT: Do I need to commit my branch before checking out another branch, what about stashing?

六眼飞鱼酱① 提交于 2019-12-12 07:14:35
问题 I'm new to Git and a bit confused. I have a Master branch and have created a second feature branch. If I make changes in my feature branch and then switch to Master, will my changes be lost if I don't commit? Where does stash come into play, is it something you do before you switch branches (but don't want to commit) or is it to simply revert some changes so you can get back to previous code temporarily? 回答1: You can't change to another branch unless you clean your tree. This is done by

After merge, how does the commit ID of a merged file (no conflicts) change?

♀尐吖头ヾ 提交于 2019-12-12 06:52:42
问题 Suppose we have branch A, and branch B. Branch A works on file a.cpp, and have several commits say commit ID 10000 10001, 10002, 10003 (faked). Branch B has a.cpp. a.cpp still shows the old commit ID 10000. [Note] Branch B has other commits already. But a.cpp history in Gighub only show one old commit ID 10000. Now we merge A to B. In B, we have a.cpp. What are its history commit ID series "FOR a.cpp File"? I didn't mean the commit history for B. I mean the history for the file a.cpp (you

How do I undo the most recent local commits in Git?

北战南征 提交于 2019-12-12 03:26:15
问题 I accidentally committed the wrong files to Git, but I haven't pushed the commit to the server yet. How can I undo those commits from the local repository? 回答1: Undo a commit and redo $ git commit -m "Something terribly misguided" # (1) $ git reset HEAD~ # (2) << edit files as necessary >> # (3) $ git add ... # (4) $ git commit -c ORIG_HEAD # (5) This is what you want to undo. This does nothing to your working tree (the state of your files on disk), but undoes the commit and leaves the

Is it possible to automatically split a commit for Github compare view?

﹥>﹥吖頭↗ 提交于 2019-12-11 20:23:03
问题 At our company code reviews are done in Github compare view by adding comments. Of course you can use difftool or someting. But I'd like to know if there is a way to automatically warn / split a commit when it exceeds the Github limits? 回答1: You can use a pre-commit hook to prevent large commits. E.g. to check the diff's number of lines, save the following as [REPO PATH]/.git/hooks/pre-commit and make it executable (e.g. chmod +x on linux): #!/usr/bin/env bash [[ $(git diff --cached | wc -l)

how to combine commits and push to the remote

≯℡__Kan透↙ 提交于 2019-12-11 18:43:47
问题 At the beginning the local branch is uptodate and now I use git rebase -i HEAD~3 and modify the pick of the two newest commits to fixup to combine 3 commits at the local branch,and now I want to push the local branch to the remote. And I only want to show a combined commit at the remote. However,after combined the local branch falls behind with remote by two commits and I cannot push directly. How can I deal with it? 回答1: DISCLAIMER : git push --force is dangerous; use it at your own risk. If

Git reset failing after find and replace

故事扮演 提交于 2019-12-11 11:01:38
问题 No git's command is working anymore created a branch, made some commits. Then I made a recursive find and replace as so : LANG=C find . -type f -name '*.*' -exec sed -i '' s/My\ sentence/My\ sentencevotre/ {} + which worked properly, but now I can't commit, I can't reset hard, I have a serie of messages when reseting : error: packfile .git/objects/pack/pack-$SHA.pack does not match index ... and when commiting : warning: packfile .git/objects/pack/pack-$SHA.pack cannot be accessed .... error:

LibGit2Sharp get repository changes after pull

夙愿已清 提交于 2019-12-11 10:25:01
问题 How can i get the following information after a git-pull with libgit2sharp: Which files has been moved Which files has been created Which files has been deleted The git-pull request it self works perfectly: var result = repo.Network.Pull(new LibGit2Sharp.Signature("admin", "mail@......net", new DateTimeOffset(DateTime.Now)), options); I already looked at the result of the Pull -Method, but this seems not to contain the needed information. Thank you very much! 回答1: The MergeResult type exposes

Updating and committing file by using gitlab api

空扰寡人 提交于 2019-12-11 07:00:01
问题 I want to update file content and commit it. To be able to achieve it, I looked the api of gitlab from the url; http://mygitlabadress/help/api/README.md It says Updating existing file is done as; http://mygitlabadress/help/api/repository_files.md#update-existing-file-in-repository I follow the instructions and write; http://mygitlabadress/api/v4/projects/:id/repository/files/file1%2Ffile2%2Ftest?ref=master&author_name=name%20surname&content=some%20other%20content&commit_message=update%20file

git commit can't find (global) config running in cron job

我与影子孤独终老i 提交于 2019-12-11 06:30:49
问题 I want to commit some file changes using a cron job calling a script with the following line in roots crontab 0 * * * * cd /files/ && ./backup.sh >/tmp/cronlog 2>/tmp/cronerror the script looks as follows: #!/usr/bin/env bash … prepare the files for the backup … echo "commit changes …" git add -u git commit -m "backup" git push Prior to the cron setup I've also set user.email and user.name for the root user and I've checked that the script runs if I call if from the command line. But in /tmp

Git Merging selected branches into a new branch, retaining access to the branches

╄→尐↘猪︶ㄣ 提交于 2019-12-11 04:24:41
问题 What exactly do I type to go from: (I also get a sense from other people that my drawings suggest I don't quite understand git - bear with me.) -<>-<>-<>-<>- (B) / -----master- \ --<>-<>- (A) where '<>' is a commit. to this: (merge A and B into C) --------------o-> (C, new 'clean' branch off master) / / /-<>-<>-<>-<>-/ (B) // / -----master-- / \ / --<>-<>-/ (A) where 'o' is a merge of A and B into C. And will I then still be able to git check-out the branches (A) and (B) ? And/or could I do