Git checkout does not change local files/folders

Asked

Viewed 886 times

3

I’m starting to get into GIT. And a problem came up.

Apparently, the checkout was not altering the local files.

Let me explain it better:

My stream is simple, clone, change code, commit, push/pull, branch, checkout and some merges.

So, I made a new branch to tidy up the project’s folder structure.

I removed some, moved others, created new folders, etc. I adjusted everything to make the project work.

When I did git status, I received a giant list of deleted or created folders/files. I went to see an easier way to do git rm and add. So with git add --help, I decided that add --all was a good solution for me.

I committed and pushed, then I left.

In the morning, my team took the branch where I changed the paths of the folders and started working. Later, when I arrived, I decided to pull to get the group’s changes.

I went from branch to branch to see the changes (checkout branch-name).

I realized that all the branchs were wrong, and I started researching why. I soon came to the conclusion that when checking out among the branchs, my new structure continued, and mixed with the old folder structure.

I tried to reset HEAD --hard, but I couldn’t. I noticed that regardless of the commit you were in, the files weren’t changed.

The way was to make a new clone of the project. I imagine this was a nut solution, but after hours, it was the solution.

I wish I knew what I did wrong, to make it happen.

Anyone have any idea? My concept about checkout is misguided?

  • Well, explaining this way doesn’t help much for me to be able to help, but you did check the following: 1. The changes actually went to the remote repository ? 2. You are on the correct branch ? 3. You tried to clone a new directory to see the structure ? 4. When you pulled, was it successful ? you saw the change logs ? Not the solutions, but it will help you check where your error is.

  • @Josuéeduardo 1) yes, the changes went to the repository. 2) Yes, I am in the correct branch. 3) Yes, in the end, it was the solution I had to get back to work, I made a clone in another directory. 4) Yes, there was no conflict in Pull. 5) I don’t know how to check logs... I will arrange this.

1 answer

3

Cutia,

I believe there is an error in your procedure. I follow a procedure similar to yours and missed something. Look at the steps I take:

git pull
git checkout -b mytest

Here I work a lot, test and am satisfied... So:

git checkout master
git merge --no-ff mytest

Those steps above is what I think you needed to do.

git branch -d mytest
git commit -m "Explicação do que fiz"
git push

From what I noticed you didn’t go back to your master and merge the branch you created. What will matter to your team is the master (or whatever name you give around).

Hugs,

  • We’re actually working on a new feature, so everyone on the team would use this branch, not the master. For another part of the team, would continue on things of less weight.

  • Missing procedure on git add terminl .

Browser other questions tagged

You are not signed in. Login or sign up in order to post.