(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.
Related
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 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.)
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.
I am running etckeeper on two different machines, boxA and boxB. The OS, etckeeper repository and all, on boxB was copied from boxA back in January. In order to apply some setup changes made on boxA to boxB, I added the repository on boxA as a remote repository on boxB with the intention of doing some cherry picking, eg:
git remote add boxA ssh://boxA/etc
git fetch boxA
git cherry-pick xxxx # never got this far
The problem is that the most recent commits are not available on boxA, only commits up until late February. So far I have tried:
doing git show with one of the missing commit numbers - this is definitely not a problem with git log just not showing all the commits.
copying the full /etc on boxA to boxB and adding/fetching it via its path - this is definitely not an issue somehow introduced by ssh (to complicate things I was using a script via the GIT_SSH environment variable to avoid creating a root login).
git fsck on both repositories (no problems found).
running the following command on copied version of both repositories (after doing a git remote remove boxA on boxB and before readding):
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 \
-c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc \
--aggressive
How can I get git fetch to retrieve all of the commits?
So the problem here turned out to be that there was a detached head in the repository on boxA after an incomplete fix of a botched rebase. When this happens the output of git branch is as follows:
# git branch
* (no branch)
master
The fix was simply to create a branch on boxA and then merge it:
git branch temp
git checkout master
git merge temp
git branch -d temp
After that all the commits on branch master (or at least what I thought was branch master) were available after doing another git fetch.
I am having a situation here. I did some commit to master branch and after move these commit to
other branch x using and
git cherry-pick
and I run git cherry-pick on x branch itself. Now after this git cherry-pick, forgot to run git push command.
Almost at same time my colleague did the git cherry-pick for his commits and did the git push.
When I see the git log on his machine I couldn't find my commit and realize that I forgot to run git push.
I went to my machine, did the git push. But I am seeing this message now
Without a better log output it is hard to tell, what happend.
I guess you both had the same base commit, each of you did a cherry-pick, and you merged both cherry-picks in order to be able to push it.
The log above shows one commit from you (cf5b726), one commit from your colleague (1aa2ecd) and a merge (28529d0) of the first two commits, which seems to originate from a git pull.
And yes, the merge carries the changes of both merged commits. - After all that's exactly the point of a merge. ;)
You can use git log --graph or git log --format=raw (or magit for Emacs) to see the parents of a commit.