adding all git history to a project whose history was not copied
I have the actual situation:
There is a project in which I have been working. It is git controlled.
Another person copied the project but did not copy the .git folder and the .gitignore and .gitattributes files.
After that he made an interesting modification that I would like to integrate into the project.
My original question was going to be: How can I put all the original history to this last version of the project, but I think I have solved it, it is rather simple: I copied the .git and .gitignore .gitattribute files to the project and it immediately has the project git controlled (and of course I still need to commit the changes)
All nice and good except one thing that is bugging me. Now among the things I have to commit there is the "add .gitignore file".
Does that mean that this was lost from the previous commits???
git
add a comment |
I have the actual situation:
There is a project in which I have been working. It is git controlled.
Another person copied the project but did not copy the .git folder and the .gitignore and .gitattributes files.
After that he made an interesting modification that I would like to integrate into the project.
My original question was going to be: How can I put all the original history to this last version of the project, but I think I have solved it, it is rather simple: I copied the .git and .gitignore .gitattribute files to the project and it immediately has the project git controlled (and of course I still need to commit the changes)
All nice and good except one thing that is bugging me. Now among the things I have to commit there is the "add .gitignore file".
Does that mean that this was lost from the previous commits???
git
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
Likely you need to check your previous git state. I would suggest to usegit worktree
functionality (use a separate folder for the project with a chosen git state) or simply rungitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed.gitignore
file in that folder or something like that.
– user3159253
Nov 16 '18 at 9:09
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26
add a comment |
I have the actual situation:
There is a project in which I have been working. It is git controlled.
Another person copied the project but did not copy the .git folder and the .gitignore and .gitattributes files.
After that he made an interesting modification that I would like to integrate into the project.
My original question was going to be: How can I put all the original history to this last version of the project, but I think I have solved it, it is rather simple: I copied the .git and .gitignore .gitattribute files to the project and it immediately has the project git controlled (and of course I still need to commit the changes)
All nice and good except one thing that is bugging me. Now among the things I have to commit there is the "add .gitignore file".
Does that mean that this was lost from the previous commits???
git
I have the actual situation:
There is a project in which I have been working. It is git controlled.
Another person copied the project but did not copy the .git folder and the .gitignore and .gitattributes files.
After that he made an interesting modification that I would like to integrate into the project.
My original question was going to be: How can I put all the original history to this last version of the project, but I think I have solved it, it is rather simple: I copied the .git and .gitignore .gitattribute files to the project and it immediately has the project git controlled (and of course I still need to commit the changes)
All nice and good except one thing that is bugging me. Now among the things I have to commit there is the "add .gitignore file".
Does that mean that this was lost from the previous commits???
git
git
edited Nov 16 '18 at 8:34
KansaiRobot
asked Nov 16 '18 at 8:27
KansaiRobotKansaiRobot
9381430
9381430
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
Likely you need to check your previous git state. I would suggest to usegit worktree
functionality (use a separate folder for the project with a chosen git state) or simply rungitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed.gitignore
file in that folder or something like that.
– user3159253
Nov 16 '18 at 9:09
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26
add a comment |
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
Likely you need to check your previous git state. I would suggest to usegit worktree
functionality (use a separate folder for the project with a chosen git state) or simply rungitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed.gitignore
file in that folder or something like that.
– user3159253
Nov 16 '18 at 9:09
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
Likely you need to check your previous git state. I would suggest to use
git worktree
functionality (use a separate folder for the project with a chosen git state) or simply run gitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed .gitignore
file in that folder or something like that.– user3159253
Nov 16 '18 at 9:09
Likely you need to check your previous git state. I would suggest to use
git worktree
functionality (use a separate folder for the project with a chosen git state) or simply run gitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed .gitignore
file in that folder or something like that.– user3159253
Nov 16 '18 at 9:09
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26
add a comment |
1 Answer
1
active
oldest
votes
I would suggest to do a git add .
then commit all changes as you would normally do. Then reapply your .gitignore as described in this answer to be on the safe side.
git add .
git commit -am "added new feature"
git rm -r --cached .
git add .
git commit -am "fixed untracked files"
Make sure to commit your changes before doing the git rm -r --cached .
or you will loose them.
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334005%2fadding-all-git-history-to-a-project-whose-history-was-not-copied%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would suggest to do a git add .
then commit all changes as you would normally do. Then reapply your .gitignore as described in this answer to be on the safe side.
git add .
git commit -am "added new feature"
git rm -r --cached .
git add .
git commit -am "fixed untracked files"
Make sure to commit your changes before doing the git rm -r --cached .
or you will loose them.
add a comment |
I would suggest to do a git add .
then commit all changes as you would normally do. Then reapply your .gitignore as described in this answer to be on the safe side.
git add .
git commit -am "added new feature"
git rm -r --cached .
git add .
git commit -am "fixed untracked files"
Make sure to commit your changes before doing the git rm -r --cached .
or you will loose them.
add a comment |
I would suggest to do a git add .
then commit all changes as you would normally do. Then reapply your .gitignore as described in this answer to be on the safe side.
git add .
git commit -am "added new feature"
git rm -r --cached .
git add .
git commit -am "fixed untracked files"
Make sure to commit your changes before doing the git rm -r --cached .
or you will loose them.
I would suggest to do a git add .
then commit all changes as you would normally do. Then reapply your .gitignore as described in this answer to be on the safe side.
git add .
git commit -am "added new feature"
git rm -r --cached .
git add .
git commit -am "fixed untracked files"
Make sure to commit your changes before doing the git rm -r --cached .
or you will loose them.
edited Nov 16 '18 at 16:00
answered Nov 16 '18 at 9:13
b-fgb-fg
2,09011624
2,09011624
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334005%2fadding-all-git-history-to-a-project-whose-history-was-not-copied%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I would like to ask you to elaborate the "add .ignore file" thing. What is it, exactly?
– user3159253
Nov 16 '18 at 8:31
adding the .gitignore file to a commit
– KansaiRobot
Nov 16 '18 at 8:35
Likely you need to check your previous git state. I would suggest to use
git worktree
functionality (use a separate folder for the project with a chosen git state) or simply rungitk --all
and view what files and with what content exist in the last committed version. Perhaps you never committed.gitignore
file in that folder or something like that.– user3159253
Nov 16 '18 at 9:09
@KansaiRobot did my answer helped?
– b-fg
Nov 20 '18 at 8:26