Posts

Showing posts with the label git

How can one change the timestamp of an old commit in Git?

Image
Clash Royale CLAN TAG #URR8PPP How can one change the timestamp of an old commit in Git? The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the original commits. This seems logical, but is there a way to also re-set the times? Related: How to change git log date formats – kenorb Mar 14 at 11:52 17 Answers 17 Use git filter-branch with an env filter that sets GIT_AUTHOR_DATE and GIT_COMMITTER_DATE for the specific hash of the commit you're looking to fix. git filter-branch This will invalidate that and all future hashes. Example: If you wanted to change the dates of commit 119f9ecf58069b265ab22f1f97d2b648faf93...

git pull issue without user name

Image
Clash Royale CLAN TAG #URR8PPP git pull issue without user name I hosted a third_party project on server-1/repo1. This third_party project is added as ExternalProject in repo2 cmake (The real project). The repo2 is our work. Our build environment is docker based. Inside Docker, I am able to clone the repo1 as per configuration of ExternalProject in repo2 cmake. However git pull aka "UpdateCommand" for External Project is failing. It is failing because I don't have git "user.name" and "user.email" set inside docker. As per my thinking, I don't need git "user.name" etc config inside docker for the third_party repo. The git fetch works inside docker. The git pull is going to add merge commit and probably that's why it need git "user.name" etc. To avoid this, I tried git pull --no-commit, but still land into this issue. Does anybody have insight? The "User Name" for user inside Docker is "User" and There ...

GIt connection closed by remote host

Image
Clash Royale CLAN TAG #URR8PPP GIt connection closed by remote host I just configure two ssh keys on git, but when i test ssh connection it returns a error,here is the debug log: debug1: key_load_public: No such file or directory Connection to code.aliyun.com closed by remote host. Connection to code.aliyun.com closed. Transferred: sent 2528, received 1472 bytes, in 0.0 seconds Bytes per second: sent 12863830.2, received 7490331.5 debug1: Exit status -1 I don't know where went wrong, I have send the public key to the sever and still got a error,thanks By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Error when changing to master branch: my local changes would be overwritten by checkout

Image
Clash Royale CLAN TAG #URR8PPP Error when changing to master branch: my local changes would be overwritten by checkout This question is similar to this one, but more specific. I have a project with two branches ( staging and beta ). staging beta I develop on staging , and use the master branch to fix bugs. So if I'm working on staging and I see an error, I change to master branch: staging master master git checkout master and do the stuff: git add fileToAdd git commit -m "bug fixed" and then I merge with both branches: git checkout staging git merge master git checkout beta git merge beta And doesn't matter if there are other files on the working tree. But now, when I try to change to the master branch, I'm getting an error : master error: Your local changes to the following files would be overwritten by checkout: src/Pro/ConvocationBundle/Controller/DefaultController.php Please, commit your changes or stash them before you can switch branches. Aborting I thou...

I can't do “git push origin master”

Image
Clash Royale CLAN TAG #URR8PPP I can't do “git push origin master” when I try to do git push origin master I always get one of these messages I tried bitbucket only is there is a problem with git commands or something? error message 1 error message 2 Can you be more specific? – bstrauch24 26 mins ago the full detailed errors on the two images – Islam Moustafa 21 mins ago 1 Answer 1 To resolve the first error message, make sure you've properly generated an RSA key pair and uploaded the public key to bitbucket in your settings. The second error message is appearing because you need to run git pull befo...

How to have a tracked file in a git repo that doesn't change from branch to branch

Image
Clash Royale CLAN TAG #URR8PPP How to have a tracked file in a git repo that doesn't change from branch to branch What I’m sort of looking for: I’m looking for a way to have a file or (better yet) a directory in a project repo that is part of the repo (tracked), but is left unchanged by switching branches. Also, know that I am not adverse to considering something other than Git. Its just what I'm use to. Use case: I have a personal project which I want to apply the magic of git to. There is one catch so far. I have a file that is not part of the actual code. It is not meant for production. Its sole purpose for existence is so that I have a place to write down ideas when they come to me, or to brain storm when I'm stuck. I usually am editing this in parallel with whatever else I'm doing, and I keep it open at times. It doesn’t matter what I’m doing, its the same file whose contents are in no way dependent on what branch I’m on. I do not want this file altered when I swit...

What's the best practice for amending a merged remote branch?

Image
Clash Royale CLAN TAG #URR8PPP What's the best practice for amending a merged remote branch? For example, I've finished a feature branch, pushed and merged it into the remote develop branch. After 3 days, I find a typo on that branch, then what's the best way to amend that branch. Create a new branch to correct that trivial mistake or re-work on the old branch? Could you please give an example with git commands for this? Thanks! 1 Answer 1 If I understand correctly, you're talking about a policy issue, not really a technical one. The technical part is the same - you'd treat it as any other change. Another branch to be merged in, if that is your workflow. Whether or not you're committing that new typo on a new branch or the just-merged old branch doesn't matter to git, the tree looks the same in both cases. Here's how it would look like after the merging of your mino...

is there a way to compare existing docker image with latest source (Git) and build it only when there is any code change?

Image
Clash Royale CLAN TAG #URR8PPP is there a way to compare existing docker image with latest source (Git) and build it only when there is any code change? I have a gradle task which creates a docker image using the product code in Git. When the task is run docker image is created and pushed to repository/hub. But I would like to have a check where I do it only when there is a code change compared with last/latest docker image. 1 Answer 1 One way of doing this would be to wrap your docker build in a shell script. This script will build the image with a label whose value is the commit hash. The script will also check the value of this label for the current image and will compare it with the current commit hash before building. docker build By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy...

Git summary statistics between two tags

Image
Clash Royale CLAN TAG #URR8PPP Git summary statistics between two tags I asked a question Git statistics on all files, between two tags some time ago, and got two nice answers. However, I now need to get how many lines of code is added and deleted between two tags. So, just two numbers, not broken down by files. Obviously, I can run git diff --numstat, and than sum data for all files. But, is there a direct way to get these rwo numbers from git? Does --shortstat work for you? – Ry- ♦ 6 mins ago --shortstat 1 Answer 1 git diff --shortstat tag1 tag2 documentation By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that y...

git: undo all working dir changes including new files

git: undo all working dir changes including new files How to delete all changes from working directory including new untracked files. I know that git checkout -f does that, but it doesn't delete new untracked files created since last commit. git checkout -f Does anybody have an idea how to do that? @Joel & Wayfarer: why don't you try git help reset and git help clean – SHernandez Jan 4 '15 at 16:53 git help reset git help clean Making an alias for this in your git config is a good idea ;) – anubina Sep 9 '15 at 17:02 12 Answers 12 git reset --hard # removes staged and working directory c...