I do not understand why the same command works on linux and not on windows. Is the pathspecs syntax differ or there is a problem on the git windows version?
On windows (git version 2.31.1.windows.1)
git status -- 'src/test.js'
On branch master
nothing to commit, working tree clean
On linux (wsl: git version 2.25.1)
git status -- 'src/test.js'
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/test.js
A classic git status gives the same result between linux and windows.
As you saw on the Git mailing list, this is actually a cmd.exe issue: running:
git status -- 'src/test.js'
passes the literal string:
'src/test.js'
to Git, rather than passing:
src/test.js
to Git. As a result Git is looking for the file name including the quotes. (The easiest solution is to omit the quotes, which are not required on either system for this pathspec: neither has any characters special to any shell or CLI.)
Related
(new to linux terminal, comming from git bash)
Linux terminal isn't showing the git command response in some cases. Git branch for example. git branch does not list branches (git branch -l doesen't work either), but there clearly is a branch since git status returns it.
Any ideas on what could be the problem? Should I use different command line?
A branch with no commits yet doesn't yet really exist, when you commit the first time that's the one you'll make. git status shows you as "on" that branch because that's the tip you'll commit to, git branch doesn't show you that branch because you can't do anything (else) with it yet.
When I run git branch -a in a folder with a .git directory, NOTHING is returned. I have been working in this directory for a few months and git branch used to return all local and remote branches.
My PyCharm IDE can still see all of the branches just fine.
I have searched for answers throughout SO and other sites to no avail.
git branch used to return all local and remote repositories.
Only git branch -a would return all local and remote tracking branches (branches, not "repositories").
Check first if, as commented, this is a pager issue. Change shell (if you are on Windows, switch between CMD, Powershell or bash, to see if the issue persists)
git --no-pager branch does work!
How do I fix git branch based on this info?
As noted in git config:
To disable pagination for all commands, set core.pager or GIT_PAGER to cat.
git config core.pager cat
But for disabling it only for git branch, you have various options as described in the similar question "How do I prevent 'git diff' from using a pager?"
An alias for git -P branch would be one of them. (-P is --no-pager)
I'm new to Git. We're in Linux, and I just inherited someone's project family.
I recently did:
git add Bom.xml Bom.csv N.cpp makefile ../mm
git commit -a
(said On branch Bom, your branch is ahead of master by 2 commits. use git push to publish your local commits. Untracked files: list of things I don't want to commit anyway). Nothing added to commit but untracked files present.
then
git push
But it said everything up-to-date. I'm not sure where to look to see that my content is pushed up to my branch on the server. I know I had file changes since my last commit. It's a tough thing to search for the answer online. I looked at up-to-date too, and added the git add and the -a to my commit, but it still says up-to-date when I try to push.
Thanks!
Mich
Like the link you mentioned, make sure you have added the file you want to commit into the staging area. Each time you want to commit
run git status to check.
And then run git add file to add file to staging area.
Run git status to check whether the file is added to the stage.
Then run git commit -m "some message" to commit
run git log to check your commit history check whether you have committed successfully
then check your remote branch by running git branch -a
if your remote branch doesn't have your local branch branch-name
then run git push origin branch-name to push your local branch to remote.
The other day I had to have a full image restore of one of our production servers due to a problem encountered with git and not having any clue how to solve the issue. The standard workflow, which has worked for almost 2 years without a problem has been:
Make local changes
Commit
Finish feature (GitFlow)
Push to remote origin
Login to server, go to http root and issue the following command:
git pull master Version_1.x.x
However, this time instead of this working as usual I was presented with this error.
fatal: failed to open 'app/lang/en/homepage.php': File exists
That file was updated in dev as were several other files. I immediately got server monitoring notification that the website was no longer responding. So I loaded it up and I got a 404 error??
Returning to the console I did git status and was blown away with what was shown.
On branch master
Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: app/views/layouts/landingBody.blade.php
modified: app/views/layouts/trailblazers.blade.php
modified: app/views/mobile/UI/landingBody.blade.php
modified: public/images/spashPage_full_new.jpg
Untracked files:
(use "git add <file>..." to include in what will be committed)
public/images/3rd_Party/
public/images/UI_bg_login_summer2015.jpg
public/images/spashPage_full_1024_summer2015.jpg
public/images/spashPage_full_1200_summer2015.jpg
public/images/spashPage_full_blur_summer2015.jpg
public/images/spashPage_full_summer2015.jpg
no changes added to commit (use "git add" and/or "git commit -a")
How is this possible that files have been changed in production and files that were part of the latest update were reporting as untracked files?
So I tried stashing the changes which predictably returned the following on the next git status
On branch master
nothing to commit (working directory clean)
I tried everything from reset hard to reset to a specific commit and it progressively got worse to the point I was getting.
I got errors such as
git reset --hard ORIG_HEAD
error: git checkout-index: unable to create file app/3rdParty/Mobile_Detect.php (File exists)
error: git checkout-index: unable to create file app/config/app.php (File exists)
Not knowing what else to do, I did a full restore from a snapshot. Now that I am back to the last backup, which was less than 16hrs old, and no other changes made since then I do a git status on the same production machine. Just to check before actually issuing another git pull command and messing everything up again. The following was result:
On branch master
Changed but not updated:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: public/.htaccess
Untracked files:
(use "git add <file>..." to include in what will be committed)
app/config/auth.php
app/config/cache.php
app/config/compile.php
app/config/database.php
app/config/remote.php
app/config/session.php
app/views/emails/
app/views/hello.php
bootstrap/compiled.php
readme.md
no changes added to commit (use "git add" and/or "git commit -a")
Again how is this possible? Nothing is ever done in production except git pull <local branch> <origin branch>, yet there are untracked files and modified files.
I have updates which need to be "pushed" into production but I can't have the website go down again. Not being a git expert makes this especially difficult.
I did check the git log on production and compared it with the origin, and dev and the commits all match up. This is all very perplexing.
Any help would be greatly appreciated.
The problem was within dropbox. The .gitignore file for one of the sub directories was removed and replaced with an alternate version and was unintentionally pushed in a previous release. The next time it was time to update everything was completely out of whack. Replacing the .gitignore file with the correct version and doing a hard reset, followed by a pull resolved the issue. Lesson: Dropbox can be dangerous when playing in the same sandbox as git.
I have an old Synology DS-106j server where I tried to install git using ipkg command. The installation went smoothly, but git failed to work correctly. I am currently learning how to use git, so I don't know if it is a bug from git with the version I am using or something else is wrong.
What I did was create a new local repository with a specified name, add a new file, commit it, and got an error:
NAS_SERVER> git init Test
Initialized empty Git repository in /root/Test/.git/
NAS_SERVER> ls
Packages.gz git_1.8.4.2-1_powerpc.ipk
Test
NAS_SERVER> cd Test
NAS_SERVER> git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
NAS_SERVER> touch Test.cs
NAS_SERVER> ls
Test.cs
NAS_SERVER> git add *
NAS_SERVER> git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: Test.cs
#
NAS_SERVER> git commit -m "Test"
fatal: 57e2b8c52efba71d84c56bf6f37581686b9061a3 is not a valid object
I thought...maybe I did something wrong, so I used git on Windows OS and try a push. Still an error. Transfer the whole repository to the server and check the status. It seems fine. Try a commit. Still the same result. What worse is that I can't update git version without having to compile it, which I don't even know how to do so. Any suggestion to what might be wrong?
If your goal is to push into a git repo located on the synology disk(s) for backup purposes I'd recommend a different approach which would avoid having to install a rather old git version on the synology box itself (which could lead to problems if/when using a newer git version on the windows machine).
Export a samba share from synology, mount it on windows and use the windows git to create the backup repo (maybe even a bare repo, eventually group shared if you plan to share work with other people). Then push from your working repo into this backup repo - all on the windows box. In this scenario the synology box doesn't need git installed, it just serves files (i.e. its original job).
I'm using such setup but with a linux machine instead of a windows one and with the bare repo on the synology disks exported via NFS instead of Samba.