git delete all files form remote branch after updating .gitignore - visual-studio

I recently started working on an open source project called "TFDT : Team Foundation Dev Tools" but I made a mistake to add a std .gitignore and now I want to fix it by adding one from https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore
I've already 10 or so commits by now and I've two branches. Is it still possible to get rid of all undesired files from GitHub's both branches that I've now ?
At the same time I also want to make sure that if someone clones my repository, they should be able to build successfully as long as my code builds on my development machine.
Compatibility : VS 2k 8, 10, 12, 13

One solution I have done is to rename the files, check them in, then rename them back to the original file name and check them in again. For example, if you want to gitignore a file called config that is already tracked, add it to .gitignore then:
git mv config config.temp
git commit -am "renaming file for gitignore"
git push origin master
git mv config.temp config
git commit -am "renaming file back to original name"
git push origin master

Related

Why are subfolders not being seen by the Git repository?

I have just created a local repository (using Git) for a project that will contain many subfolders (it is a pedagogical project with Lesson 1...2...3 etc..., each one with a folder within the main directory).
I connected this to the remote repository I created on GitHub.com and hoped that would have been enough to start working, pushing, committing etc... now that I have created the first Xcode project inside the main folder neither Xcode Commit function nor Terminal git commit command is seeing any change.
The symptoms I see are that the remote repository sees "Project name" folder, then "Lesson 1" folder inside it but nothing else inside "Lesson 1", where the Xcode project should be (it actually is there in the Finder).
What may have gone wrong?
What would have been the proper set of actions to create a repository in a directory that would automatically fetch every new file added to it?
Thank you so much!
Git will not automatically track new files you create in the directory tree which contains your local git repo.
When you create new files, you need to inform git that you want them tracked, with the "git add" command.
git add path-to-new-file
If you create new files and do not add them, then when you run the "git status" command the output should contain a section labeled Untracked files, like this:
Untracked files:
(use "git add ..." to include in what will be
committed)
asdf.txt
It will show the path to the file(s) relative to the top of your git repo, including the filename(s). Pass all of that to the git add command. Then commit, just as you would for changed files.

Ios git merge conflict in xCode

I have two branches in my project, one is develop and other is master, accidently without merging develop into master I made app live and now I have two different versions on two different branches. Let's say 1.5 version on master and 1.6 on develop, now when I tried to merge these two branches git show merge conflicts in 3 different files,
.plist
.xcodeproj
.xcworkspace
after merge when I tried to open xCode project, it failed and show error "project cannot be load.." when tried to open files manually it just doesn't open in editText. I tried sublime editor but then again I couldn't locate conflict as there were a lot of lines of code.
If you want to replace master content with dev, you should:
do a merge from master to dev, keeping dev content
then do a trivial merge from dev to master
That is:
git checkout dev
git merge --ours master
git checkout master
git merge dev
You can resolve conflicts by keeping any version (keep mine or keep theirs) of this files as they save the xcode status but they don't have your code and should not have been tracked. But don't resolve the conflicts yourself, just choose one of the versions and the project should work.
You are having this problem because you should have created a .gitignore file in your repo before creating any other file to avoid having problems with files that your ide uses but don't have the code of your app.
To avoid problems from now on, you can create the git ignore file with this content and add it to the repo.
But there are files traked that should not be. So execute this commands:
git rm -r --cached .
git add .
git commit -m "use .gitignore file"
This will delete everything from the index and add the files again applying the gitignore rules.
Check that all is working and git push to your server and you should not have more conflicts with this files for saving the xcode status.
Hello #Najam you can make change in remote branch push it to master and then try to merge remote and master
git merge remote mater:master
or you can delete the remote branch and push your remote code to master branch.

I have deleted my project.pbxproj file using git checkout -- <file>. Should I delete the branch locally and pull from origin?

I have gotten myself into some hot water regarding source control.
I had just gotten a feature branch to work that another developer on my team had created and developed, which required adding some files. He then added some additional code to the project, and I wanted to revert to the version of the branch I had started with before I pulled his new code so that I wouldn't have to worry about merging these new files.
So, as per git's recommendation, I unstaged the changes I had made and used:
git checkout -- ScrollingTextLabels.xcodeproj/project.pbxproj
followed by:
git pull
I had assumed that the pull would replace the project.pbxproj file with the one from the origin, but instead git spat out a lot of lines beginning with "delete mode", most disconcertingly:
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
Every time I try to open the project on this branch, I now get the following error message from Xcode:
Project /Users/myname/Documents/Code/organization/product-ios/ScrollingTextLabels.xcodeproj cannot be opened because it is missing its project.pbxproj file.
I have been able to switch to other branches, which are still working fine, and must have their project.pbxproj file.
Also, I attempted to use git reset --hard to no avail. Should I force an overwrite (a la How do I force "git pull" to overwrite local files?)?
Should I delete the branch locally and pull from origin?
All I want is for the remote version of this branch, which is working well, to appear unchanged on my computer so that I can open it and continue working.
The message
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
during a merge (or pull) indicates that the file was deleted in the to-be-merged branch. It does not exist anymore in the other branch, your co-worker must have deleted that file.
Deleting a branch and pulling does normally not solve anything. You already have all changes from the remote (probably in origin/branch). Either checkout a new branch from that commit, or reset to it (potentially losing all your local changes!)
Use git log origin/branch or gitk to view the changes of the branch. You can also show the log for this single file only with git log origin/branch -- ScrollingTextLabels.xcodeproj/project.pbxproj. This should tell you, what happened to the file and whether it was deleted in the branch.

How to recover files in git repository

I had a project connected to a local git repository. I decided to reinit that after some mess with branches and commits. Firstly, I deleted old repository with "rm -r .git", and than created new one with "git init". After that, I found out my work directory looking the same way as if my project was only created - the results of all my work are gone.
Trying many recipes from the internet didn't give results. Please, give me a cue, is there any chance to recover my project's files or not.
In the case your "local repository" means you did git clone /path/to/your/local/repo, yes you can restore it by cloning again with git ckibe /path/to/your/local/repo, or git remote add origin /path/to/your/local/repo && git fetch && git pull origin/master ).
Same thing if you cloned from a remote repository.
Otherwise, there is no way to recover your files with git, except if you removed by a graphical interface (which move to a trash folder instead of making a real deletion) or if you have a back up.

Git: cannot open .pbxproj file error after renaming Xcode project and pulling changes

I renamed our iOS project (client finally chose a name) following instructions in the most upvoted answer here. I pushed my changes. Now, when my teammates pull, they cannot open the project because Xcode cannot find the .pbxproj file. They subsequently reset to their good local versions.
As usual when I royally f**k up I tried a hard reset to the last good commit, planning to force push the good commit up to the remote. While the reset was 'sucessful', it didn't change the newName.pbxproj back to oldName.pbxproj. So I could not open the project. Checking out my faulty commit didn't help things either. I am back at square one.
.pbxproj is NOT in our .gitignore:
*.DS_Store
*.xcodeproj/xcuserdata/*.xcuserdatad
*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
*/*.xcodeproj/xcuserdata/*.xcuserdatad
*/*.xcodeproj/project.xcworkspace/xcuserdata/*.xcuserdatad
The only thing I can think of now is to reclone the project from a specific remote commit. How can I do this? Other options? Why won't a renamed .pbxproj transfer over in a pull?
If you do a git log -5 it will show your last 5 commits. Determine the version before you named the file, and you can do a git reset --hard HEAD~<number> where <number> is how many commits you want to go back.
Alternatively, with your renamed proj file, you could try to blow away your remote with a git push origin :branchName then push your local changed branch up to the remote git push origin branchName
Then, have your other team members do a pull from the newly pushed remote.

Resources