1

I have a git with branch. In this branch i have checkout a particular commit to separate folder.

Now I have added some of files to this particular branch id with changes. now my time to save this to git.

But I am wondering, if I commit and push may it impact on other commits sits on top of this commit ID.

How to handle this scenario?

In case If I commit, will all changes, added files only will sit on respected commit only? - need clarity.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
  • you'll have to get the changes sitting on top of the branch id first, merge/rebase them and then push your changes. Is that what you're asking ? – s7vr May 31 '16 at 06:58
  • No, the changes on top of this ID should be there. I would like to update the changes to only on this `id` with added files. or what is the correct way? – 3gwebtrain May 31 '16 at 06:59
  • when you say branch id do you mean commit hash ? – s7vr May 31 '16 at 07:02
  • yes, exactly. i have `checkout` from my `git` say 8th commit from 10 existing commits, I would like to add/update to just 8th commit only without impacting the 9,10 commits. – 3gwebtrain May 31 '16 at 07:03
  • http://stackoverflow.com/questions/1186535/how-to-modify-a-specified-commit-in-git. this will help you hopefully. – s7vr May 31 '16 at 07:06

1 Answers1

1

i have checkout a particular commit

That is a detached HEAD: you need to create a new branch where you are. It will start from the 8th commit and you can add your work in progress in it.

git checkout -b newBranch
git add .
git commit -m "new branch"
git push -u origin newBranch
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Is it required to create a new branch in the website(git repo) or withing the existing checkout folder can i run these commands? – 3gwebtrain May 31 '16 at 07:12
  • @3gwebtrain the existing checkout folder is a detached HEAD (http://stackoverflow.com/a/3965714/6309), so yes, you need to create a new branch, but its content will reflect the commit you had checked out, and won't impact the other commits above. – VonC May 31 '16 at 07:14
  • @3gwebtrain since your local folder is part of a git repo (check the output of `git status`), then yes. – VonC May 31 '16 at 07:19