Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check detailed file list to push in git

Tags:

git

I am working on a local branch (let us call it bugFix123), I normally use the following command sequences to push changes,

1. git add to add files
2. git commit -m 'description' (there could be multiple sequence of 1 and 2, suppose I have multiple commits for multiple changes, and using one single push in the final)
3. git push origin bugFix123

here is a new question, suppose I commit multiple times for multiple local changes, before I execute command git push origin bugFix123, how to see what are the final files to push? I tried to use command git commit, it seems git commit does not display the right file list to push (if there are multiple commits, before push). The purposeI want to see the final file list to push in multiple commit scenario is because I do not want to push unnecessary files and further fix them (it will send incorrect push list file notifications to others).

Edit 1,

I find git push -n not always work,

git push -n
To [email protected]:foo/goo.git
 ! [rejected]        master -> master (non-fast-forward)
 ! [rejected]        update12_1 -> update12_1 (fetch first)
error: failed to push some refs to '[email protected]:foo/goo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

regards, Lin

like image 983
Lin Ma Avatar asked Feb 06 '23 21:02

Lin Ma


2 Answers

You can use below command to list names of all changes made since last push, however it doesn't show non commit changes

git diff --name-only origin/master..HEAD

--list all commits since last push
git log origin/master..HEAD
like image 141
abhirathore2006 Avatar answered Feb 08 '23 12:02

abhirathore2006


If you've already pushed something to bugFix123 and you want to compare your local branch bugFix123 with its remote version (for instance, origin) you can do the following:

git diff --numstat origin/bugFix123 bugFix123 
like image 39
ghashi Avatar answered Feb 08 '23 10:02

ghashi