1

I have about 100 commits, and for SOME REASONS I want each one to be pushed seperately. I mean:

For example I have 1 branch named developing and this branch has 100 commits (for 1 week). I don't want to push all at once. I want git, to push the first commit, then pushes the second commit and so on, one after another. I know this might take a lot of internet and time, but I need it.

Any ideas? Or how can I write a script for it?

(I checked this. It's not my problem.)


EDIT:

I'm using gitlab. In gitlab, there are 2 options (AFAIK) to check commits. "One" is On the Project Overview tab:

enter image description here

It's problem, as I painted, is that I can't see each commit in order. I have to open each push to see innter commit. It's bad.

"The second option" is on the Repository tab:

enter image description here

And this one, it's probelm is

  1. It doesn't show all commits.
  2. It doesn't show commits date-oredered. I have to select a branch. Let's imagine I was working on 8 branches this week. I must remember branch names to check them, plus they are not in order.

I want something like:

git log #git log --oneline --graph

Thanks.

Mohammad Kholghi
  • 533
  • 2
  • 7
  • 21
  • Why do you want to do that? – John Kugelman Jan 24 '22 at 06:23
  • Git the commits to push from the log. Loop and push in order. Commits can be pushed while also specifying the remote ref (ie. branch) so there is no need to change and local branch. – user2864740 Jan 24 '22 at 06:26
  • @JohnKugelman in gitlab, if I push n commits in 1 push, I'll have problems checking them. Imagine I have commited 10 commits in 1 push, and 23 in another push. While checking commits, I have to search in pushes. But if I push them all seperately, I'll find my commit easily in the list. – Mohammad Kholghi Jan 24 '22 at 06:29
  • 2
    Uhm. That justification doesn’t make sense to me. They will *still be the same commits* at the end, regardless of the number of individual pushes.. proper branch management, commit summary messages, and PRs should be used. – user2864740 Jan 24 '22 at 06:30
  • @user2864740 OK, I have no problem looping the `git log`, but what do you mean from specifying the remote ref? Would you please make an example with the related command? like `git push ...` – Mohammad Kholghi Jan 24 '22 at 06:32
  • 1
    https://stackoverflow.com/a/3230241/2864740 shows how to specify the remote ref. Note the use of “through” in the response. – user2864740 Jan 24 '22 at 06:33
  • @user2864740 it's the gitlab's problem. I can't make GUI to show only "commits". It shows "commits in pushes", meaning you must open a push to see the inner commits. – Mohammad Kholghi Jan 24 '22 at 06:33
  • 2
    If that is indeed the case, I am so glad I don’t have to use Gitlab. Sounds like a really poor experience. (Neither Bitbucket or Github “bundle” commit-in-pushes in the UI; or at least not in any manner that prevents easily finding a specific commit.) – user2864740 Jan 24 '22 at 06:34
  • @MohammadKholghi Can you edit your question with a screenshot illustrating the problem? The commit list of a project should still show all commits. – VonC Jan 24 '22 at 08:12
  • @VonC Sure. Here you are. – Mohammad Kholghi Jan 25 '22 at 04:58

1 Answers1

1

Your initial question is answered by this snippet :

git push origin 09a079fa26e0176f13c5423a47fefb2b860205d6:draft/testing-hot-dev-branch
git push origin afeeee97560ade9067bfb3f62243c3edf804fa54:draft/testing-hot-dev-branch

Indeed you can't do it manually like that if you have 100 commits to push, you will have to script it, and ensure all people of your team use your script. And you will have to be very carefull, pushing the commits in the wrong order or forgetting a commit could be problematic.

commits pushed separetaly

In my opinion, you'd better find a solution to the underlying problem. Moreover, it would also solve the 'past', when you pushed several commits at once in the past.

About the underlying problem (You can't find a way to see all your commits, ordered by date, in Gitlab Website), a solution could be to use the Graph view, all commits of all branches are displayed, in descending chronological order.

my graph

The interface is a little misleading because it's displayed 'main' in the top of the page, but concretely all branches are in the graph. The commit SHA and a few details can be seen if you put your mouse hover a point representing a commit, and the points are clickable.

single commit view

NB1 : to produce this picture I used the commands below, you can see that I pushed my three commits in one push command :

$ git checkout -b draft/testing-hot-dev-branch origin/main

$ touch test1 && echo "1" > test1
$ git add test1
$ git commit -m "first commit"

$ touch test2 && echo "2" > test2
$ git add test2
$ git commit -m "second commit"

$ touch test3 && echo "3" > test3
$ git add test3
$ git commit -m "third commit"

$ git push --set-upstream origin draft/testing-hot-dev-branch

NB2 : if you look the XHR queries of this page, you also can see the graph in an exploitable JSON format (so I guess you can retrieve it via Gitlab API too)

XHR result from https://gitlab.com/p$groupId/projects/$your-project/-/network/main?format=json

NB3 : if you push all your 100 commits separately, a side effect will be that your pipelines will run 100 times instead of 1 time (don't know if in your context it's an advantage or an inconvenient, for me it's clearly an inconvenient)

enter image description here

  • Thanks Sir, everything is OK now. I just have 1 question: What does this mean? "effect will be that your pipelines will run 100 times instead of 1 time". And why is it bad? – Mohammad Kholghi Jan 26 '22 at 04:44
  • 1
    You can define jobs that are run automatically by gitlab each time you push (this is defined in the .gitlab-ci file). The pipeline is the set of all jobs run at each push. Generally speaking, the actions executed are 'build the app', 'test the app', 'deploy the app' but you can do what you want. In my screenshot you can see that in my 'draft' branches, 2 jobs are run (buid and tests), but when I push a tag 3 jobs are run (build, test, deploy). – Céline de Roland Jan 27 '22 at 05:13
  • 1
    You can notice that the pipeline run each time you push, not each time you commit, so if you push once for 100 commits, only one pipeline run. But if you push 100 times for 100 commits, each push will launch a Pipeline. The problems for me would be : 1) it uses resources in my remote server that execute the job and 2) it doesn't seem usefull because the commits I don't push inidividualy are typically work in progress, so testing the application is not valuable for me. I don't care if commit N°2 make my tests fail, if I resolved the issue in commit N°3. – Céline de Roland Jan 27 '22 at 05:14