![]() The currently checked-out branch in the my-project repo is feature, with only a couple untracked files, but in otherwise pristine state, and the command below indeed retrieves the snapshot at the HEAD of feature: nix-repl> builtins.fetchGit ~/clones/my-project Thanks for the extra info! When I was looking around online, every mention I found was in the context of flakes (e.g., Flakes: why do I consistently see warnings about the git tree being dirty?).įor completeness sake, I stumbled upon it while playing with builtins.fetchGit to see what happens fetching local repos of varying internal states, and when the repo was “dirty”, the builtin’s behaviour would change: Or at least that’s been my interpretation. The warning makes sure that you know your repository currently isn’t as reproducible as nix would like, despite its best efforts. It would be really annoying if you had to make a commit for every tiny change though, so nix will build dirty repositores for you anyway (but un-tracked files will be missing). The warning is probably there because nix is supposed to make sure that it builds exactly the state of the flake’s git repository - in pursuit of reproducibility it was decided that nix should add flakes to the store before building them, exactly as if someone was cloning your repository, so that you don’t get surprised by missing files down the line. Specifically, that warning pops up when you build a flake (and probably perform certain other operations on them, like nix flake check), if that flake is a git repository and git considers it “dirty” (i.e., modified, except for files that git has not yet been told to track with git add). Do this by running: git commit -m "Delete file.That’s exactly what it means in nix, as you mention As soon as you commit this change and push it to GitHub, the file will be removed from the repo on GitHub as well. Git will tell us the deleted file is staged for commit. If in doubt, carefully look at output of each command in the terminal screenshot below. Effectively, git add takes all the changes into account and stages those changes for commit. git add can be used when we are adding a new file to Git, modifying contents of an existing file and adding it to Git, or deleting a file from a Git repo. I know we are deleting the file, but we still run git add because we need to tell Git about the change we are making. If you do git status now, Git says there is a file that is not staged for commit and it has been deleted from the local copy of the repo. One way is to remove the file from our local copy of the repo with this command: rm file.txt What if we discovered we made an error and need to delete file.txt from our repo. With these steps, you can create as many files as you like, add them to Git, and commit and push them up to GitHub. This is Git's way of telling you that there is a new file in the repo directory on your computer that you haven't told Git about, and Git is not tracking that file for any changes you make. Git reports that you have an untracked file (named file.txt) in your repository. ![]() This will create a new file named file.txt. Now that we have modified a file and updated it on GitHub, let's create a new file, add it to Git, and upload it to GitHub. Run: echo "This is a new file" > file.txt I will explain what "master" means in the next article, when we discuss branching.) Add a new file to Git (To refresh your memory on what "origin" means in this case, refer to the first article in this series. The next line directs us to push those changes to origin/master, and that is what we did. The first line indicates there is one commit in the local repo but not present in origin/master (i.e., on GitHub). ![]() (use "git push" to publish your local commits) Git status says: Your branch is ahead of 'origin/master' by 1 commit The bottom-right corner of the terminal shows that I committed the changes, checked the Git status, and pushed the changes to GitHub. Once you navigate to that URL, click the "Clone or download" button, and your browser should look something like this: ![]() (If you have not yet created a Demo repo, jump back to that article and do those steps before you proceed here.) To clone your file, just open your browser and navigate to (where is the name of your own repo. Let's clone the repo, called Demo, we created in the last article. (You could also download the repo as a ZIP file, but we'll explore the clone method in this article.) What should you do? Download your files from GitHub? Exactly! We call this "cloning" in Git terminology. Say you already have a Git repo on GitHub and you want to get your files from it-maybe you lost the local copy on your computer or you're working on a different computer and want access to the files in your repository. eBook: An introduction to programming with Bash.Try for free: Red Hat Learning Subscription. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |