On Sourcetree, when I do a Commit, and I click on the project.pbxproj file I can't do a "discard hunk" because it doesn't show me inside the file, there is some preference in Sourcetree that I have to flag to be able to do a "discard hunk" even with the project.pbxproj file?
Related
So I submitted a line on Git Bash "touch README.txt -m '...asdf ... qwer...' " attempting to create a readme file with text inside (I'm obviously new to this haha). The result was an empty README.txt file and a random file titled '...asdf ... qwer...' with filetype "file" that I can't get rid of. When I try to delete or alter it, a window pops up that says "Could not find this item. ... This is no longer located in [location]. Verify the location and try again." The Git GUI doesn't seem to recognize it either and I can't delete the parent directory. Command line deletion (del /r /q "...") was unsuccessful. Tried rebooting as well to see if it disappeared. It is not a hidden file.
What exactly happened here and how do I get rid of it? Thanks!
I had a similar issue trying to delete a file that "no longer existed" on my Windows 10 PC. What worked for me was adding the problem file(s) to an archive and ensuring the option, "Delete files after compression" (or equivalent option) in the archive software was ticked. Once the archive process completed, the problem file disappeared from the folder. I then deleted the archive file and everything was good to go.
To add the file to an archive make sure you have something like 7-Zip or WinRAR installed. Here's an example using 7-Zip:
Right-click the problem file and select "7-Zip" from the context menu followed by the "Add to archive" option.
In the "Add to Archive" dialogue, tick the "Delete files after compression" option.
Select the OK button.
The problem file will disappear and an archive file will appear in your folder in its place (hopefully!).
Delete the archive file.
Hope this works for you too.
I have some troubles with Github:
When I am pushing my Xcode project to github, it seems that it won't push all files regarding the pods and app extensions because when I pull the project down on my other mac, I get a whole lot of errors that is not there on the original file.
Thanks in advance!
After a lot of testing I found the answer. When I used the command lines in terminal for pushing the project to Github, instead of the shortcuts in Xcode, I saw that this files were not "added" to the committing (I checked this by typing: git status). Then all I had to do was to write in Terminal: git add -A to add all the files. I committed and pushed them to Github, and now everything is working fine!
Thanks for all the help I got!
As shallowThought is suggesting, extend your question with your .gitignore file, so we can identify the lines that are likely preventing git from tracking the pods and extensions.
If you are unsure how to find and copy this .gitignore file, do the following:
In Xcode, on the left open the Project Navigator (folder icon) & select your project (usually the top item in the list).
From the File Menu, choose Show in Finder.
Finder will open with <your-project>.xcodeproj selected. If you don't see the folder that contains <your-project>.xcodeproj, press ⌘ 3 to tell Finder to View as Columns.
De-select <your-project>.xcodeproj and instead drag the folder that contains it onto the Terminal icon (usually in the bottom of the screen). If Terminal was not there, first start Terminal; e.g. by pressing ⌘ Space and typing Terminal.
Now, Terminal is showing the commandline in the same place where your .gitignore file usually is—technically it can be in any subfolder.
Type pbcopy < .gitignore followed by Enter to copy the contents of the file in your clipboard.
… now post the contents in your question.
Another way to check if indeed git is not tracking your desired files is opening Terminal, and running the following command (from this answer): git ls-tree -r HEAD --name-only
If Git is not tracking the files that you require, they will not be in the list.
If you want to solve this yourself, your best bet is to remove the line from the .gitignore file that is preventing Pods etc. to be tracked. So, you're are actually doing the opposite of this SO answer ;-)
In step 3. type open -a "TextEdit" .gitignore followed by Enter to open the file.
Then remove the line(s) that you don't want ignored. Save. Now you can add/commit/push the files to GitHub.
I'm new to the Git environment, and I'm using BitBucket with SourceTree on Mac. All I want to do now is to discard the changes since last commit. How should I do this? I haven't found anything like "discard changes", and directly pulling from the last commit doesn't seem to work. Solutions done with either the GUI or command line will be good.
On SourceTree for Mac, right click the files you want to discard (in the Files in the working tree list), and choose Reset.
On SourceTree for Windows, right click the files you want to discard (in the Working Copy Changes list), and choose Discard.
On git, you'd simply do:
git reset --hard to discard changes made to versioned files;
git clean -xdf to erase new (untracked) files, including ignored ones (the x option). d is to also remove untracked directories and f to force.
I like to use
git stash
This stores all uncommitted changes in the stash. If you want to discard these changes later just git stash drop (or git stash pop to restore them).
Though this is technically not the "proper" way to discard changes (as other answers and comments have pointed out).
SourceTree: On the top bar click on icon 'Stash', type its name and create. Then in left vertical menu you can "show" all Stash and delete in right-click menu. There is probably no other way in ST to discard all files at once.
Follow steps to discard multiple uncommited changes in Sourcetree.
New version of Sourcetree does not have -Reset Button- as mentioned previous answer. Thus, please follow these 5 steps for solution.
Right click "File status" and click "Reset...".
Select files. If you want, you can select all of them like the below image.
Click "Reset All".
Again click "Reset All".
Click "Reset".
Welldone..! No more 302 files to discard.
On the unstaged file, click on the three dots on the right side. Once you click it, a popover menu will appear where you can then Discard file.
Ok I just noticed that my question was already answered in the question title.
To unstage files use
git reset HEAD /file/name
And to undo the changes to a file
git checkout -- /file/name
If you have a batch of files inside a folder you can undo the whole folder
git checkout -- /folder/name
Note that all these commands are already displayed when you git status
Here I created a dummy repo and listed all 3 possibilities
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: test
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: test2
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test3
From sourcetree gui click on working directoy, right-click the file(s) that you want to discard, then click on Discard
Ok so in Windows sourcetree that is simple, on macOS I looked as well for a while..
Click Command + Shift + R while in source tree a hidden popup will be shown that will let you discard individual files OR ALL! Why is this hidden? We will never know.. but it works!
Do as follow,
Click on commit
Select all by pressing CMD+A that you want to delete or discard
Right click on the selected uncommitted files that you want to delete
Select Remove from the drop-down list
It's Ctrl + Shift + r
For me, there was only one option to discard all.
I use TortoiseGit 1.8.3.
I changed one of the files: Makefile, but I want to not offer commit it to me every once in a Git Commit.
I added it to the "delete and add to ignore list", but it does not help.
How do I make to some of the files that I have changed is not offered in the commit?
I want, that Makefile was in remote repository as read-only, that I could edit it locally, and then TortoiseGit does not offer to me to commit it.
That I wanted for Git-bash: https://www.kernel.org/pub/software/scm/git/docs/git-update-index.html
Answer for TortoiseGit 1.8.15, Git 2.6.1. There is no need to revert to the command line, all functions are directly available in TortoiseGit. I've tried to summarize the various ways how this function is accessible.
I assume that the reader knows what "assume unchanged" means. Here is easy documentation about this feature. Or the original documentation about --assume-unchanged or git ls-files.
Flag a file as "assume unchanged"
There are three possibilities in TortoiseGit: in the Commit dialog, the Working Tree dialog (Check for Modifications) or in the Log Messages dialog (only when Working dir changes entry is selected). From one of these dialogs do the following:
right-click the file and select the entry Assume Unchanged
From any file list in Windows Explorer do the following:
right-click the file and select properties
go to the Git tab
tick the entry Assume valid/unchanged
Remove the "assume unchanged" flag from a file (undo the above):
TortoiseGit allows to remove the flag only from the Working Tree dialog (check for Modifications).
in the lower left corner of the dialog: make sure to tick the option Show ignore local changeds flagged files
all files with assumed valid or skip worktree flag will be shown below the normal changed files
right-click on the file and select Unflag as skip-worktree or assume-unchanged
From any file list in Windows Explorer do the following:
right-click the file and select properties
go to the Git tab
untick the entry Assume valid/unchanged
If I'm interpreting the question correctly, Alex wants to know how to undo an --assumed-unchanged action done using Tortoise Git.
You don't need to use command line Git to fix this:
Navigate to the file(s) you did this action on in windows explorer,
Right-click and choose Properties,
Select the Git tab, there you should see a checked box next to "Assume valid/unchanged".
Uncheck it and it won't be ignored by commits moving forward.
The approved answer is good but in case you're hunting for the dialogues and options here you have a short help:
If it doesn't help, then you need to go to a command-line interface, and check:
the content of the .gitignore file that you should find at the root directory of your repo (as mentioned in "TortoiseGit: hide/remove files never to be versioned")
the result of git rm --cached Makefile.
the result of git status.
I want, that Makefile was in remote repository in read-only, that I could edit it localy, and then TortoiseGIT does not offer to me to commit it.
This is different:
You need:
git update-index --really-refresh --no-assume-unchanged Makefile
That will make any local modification to Makefile "invisible" to git, while keeping Makefile under source control.
If you want your local modifs to resist a git reset, do;
git update-index --skip-worktree Makefile
I am developing in the 'master' branch and want to copy some files from 'feature-1'. How can I do that with TortoiseGit?
(I am not interested in command-line solutions.)
tortoisegit -> show log..
in the upper part of window, select the commit (click all branches if necessary) you want the file from
copy file(s) from revision to where?
into workdir: select the file(s) you want, right-click -> revert to this revision
single file anywhere: select single file, right-click -> save revision to...
many files (that are not same as in work dir) anywhere, with directories: right-click the commit, select Compare with working copy, select file(s), right-click, export selection to..."
everything in a single commit (as zip): right-click commit, select export this version..
..or just use the command line, it's easier.
I would like to add something. In my case I was looking for specific files located in different branches, so I had to add a search text in (1) and in (2) I selected Branch. Finally, for each file I selected Revert to this revision .