To much files in commits

Hey!

in the browser:
I had a bunch of commits (first), I deleted a few of them afterwards (del), then I did a few more commits (new).

At the end, I wanted to pull the request, and instead of just (new) I could only pull (first),(del),(new).

So I started using Git in the terminal (for the first time), hoping I could delete the commits from the command line. After installing the SSH key and downloading my fork, show commit was empty.

How should I delete the logs of (first) and (del)?

Thanks

The description isn’t quite clear to me, but it sounds kind of like you’re trying to remove certain commits from the history of your branch before merging it? The Git command line is the right tool for that, though probably a rough start.

If you want to change commit history, the easiest tool is usually an interactive rebase. For details, see:
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

Hey, @airtower-luna thanks for reaching back, i still have problems, i watch tutorials, i read, but unfortunately cannot manage it, and i don’t believe it is such a unique issue

Let me describe help You understand better, what happens

BROWSER:
log in to GitHub,
go to my fork of someones repository,
click “compare” button (just below green “code” button)
and there is LIST(1) of “commits”, which i indeed made through the browser, but i dont want to pull them.

i want to clear it out - completely, and don’t look back. Instead i have a green “create pull request” button. That is is.

COMMAND LINE / Local IDE:
So i check, if i can copy the repository again, make init there and do something from the command line.

steps i did :

  1. Clone repo,
  2. git init in new directory,
  3. call git status,
    effect : different from previous (browser) LIST(2) of commits
 git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

files
files
files
files
files
files
files
files

nothing added to commit but untracked files present (use "git add" to track)

On top of that it is master branch, and i would like to go to develop branch, however command git branch -a responds with emptiness.

So as You see, i am not handling this really well yet…

Any Idea? Thanks

git init is purposefully made to be safe to run in an existing repository, with “safe” meaning it won’t destroy anything.

If you want to start a repository from nothing, just create an empty directory and run git init there. :slightly_smiling_face:

I’m not sure what you want to do with the repository you have on Github. If you want to start from scratch there’s not much point in having a fork, so it’s probably best to just delete that and create a new repository.

If the branch you want doesn’t exist yet you can create it, or rename an existing branch. If you have a master branch and want to use develop as the default branch instead, you can rename it with:

git branch -m master develop

@airtower-luna
Thanks for answer,

This post clear details, to make sure we are talking about the same thing

LOCALLY

  1. i dont want to start MY repository, but git clone other one, where i thought good idea would be to use git init (locally), bellow are some outputs of the bash commands:

#1

$ git status
On branch develop
Your branch is behind 'origin/develop' by 5 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   config.json
	deleted:    config_full.json.example
	deleted:    config_kraken.json.example
	modified:   docs/installation.md
	modified:   environment.yml
	deleted:    user_data/strategies/1. defaultBB +6609%.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	THEStrategy.py

no changes added to commit (use "git add" and/or "git commit -a")

#2

$ git branch
* develop

#3

$ git branch -m master develop
fatal: A branch named 'develop' already exists.

GITHUB
2. while using the repository on github, compare button, gives me picture bellow.
I would like that the list is empty, or eventually have just the last entry.

#1 what i see when i press COMPARE

#2 what i see when i check branches on my fork of general repository (at www.github.com)


Default branch
	
	develop

	
Active branches

	refactor/backtest
	stable
	master
	dependabot/docker/python-3.9.1-slim-buster

Summarize:
Firstly i would like to clear the pending list, to create new pull request, to safely and effectively join development of the project.

(In my head is, that afterwards, i would like to effectively bind Atom with GitHub, but at this stage it is luxury)

Hope my situation is clear now,
thanks in advance!

For the local part it looks like you are already using the develop branch, it’s just a few commits behind the develop branch on Github (assuming the remote origin is your Github repo). I’m still not sure what you want that branch to be.

There’s one crucial piece of information missing here: What are you comparing against?

@airtower-luna Ok, so we discussing 2 “branches”
(1) local
(2) web

It is confirmed, it looks like ‘origin/develop’ is active, point crossed out, point for You.

afterwards i used $ git pull twice

$ git pull
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Total 4 (delta 2), reused 2 (delta 2), pack-reused 2
Unpacking objects: 100% (4/4), done.
From https://github.com/sobeit2020/freqtrade
   3e46d1cb..a7ee0bcd  develop    -> origin/develop
Updating d5fb7741..a7ee0bcd
error: Your local changes to the following files would be overwritten by merge:
	config.json
Please commit your changes or stash them before you merge.
Aborting
$ git pull
Updating d5fb7741..a7ee0bcd
error: Your local changes to the following files would be overwritten by merge:
	config.json
Please commit your changes or stash them before you merge.
Aborting

so obviously system wants me to stash one file,
even if i am okay that the file would be simply overwritten…

$ git status
On branch develop
Your branch is behind 'origin/develop' by 6 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   config.json
	deleted:    config_full.json.example
	deleted:    config_kraken.json.example
	modified:   docs/installation.md
	modified:   environment.yml
	deleted:    user_data/strategies/1. defaultBB +6609%.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	THEStrategy.py

no changes added to commit (use "git add" and/or "git commit -a")
  • obviously i am 6 commits behind

  • as well there are some files which are deleted:, how is that? If they were deleted, i wanted them to be deleted, not to keep handling them… :slight_smile:


(2) The Web
and those things from the print screen, how to clear them out? I would like to use the web interface as well.

Many thanks for patience

These are different repositories, not branches. The distinction is important. :wink:

That is the safe suggestion. If you just want to discard your changes to config.json, you can check out the version at your current commit:

git checkout -- config.json

For more about stashing (a very useful thing!) see: Git - Stashing and Cleaning

Then you need to tell Git that, not me! :stuck_out_tongue_winking_eye: It’s the reverse of git add: If you create a new file, you need to tell Git to start tracking it. Use git rm to tell Git to delete a file and stop tracking it (and then commit). However, if you do that now you’ll have to merge the remote changes instead of doing a simple fast-forward pull. It might be simpler to check them out (see above), pull, and then delete properly.

I have no idea what you’re referring to, sorry. :sweat_smile:

Allright, the link Git - Stashing and Cleaning was helpful, good to have a whole book on the side,
that could definitely help me with command line

About the WEB, let me get it more clear
When i log to www.github.com and i go to my fork, and i click ‘compare’ (picture bellow) i get to the side, where amount of files are listed (picture). I would like to empty this list (picutre), but probably i cannot do it from the level of command line

The screenshots show that the comparison is with the repository you forked from (“upstream”). If you want there to be no difference, you need to either:

  • Get your changes merged into upstream, or
  • discard your changes.

Naturally the process is very different, and for the „merging into upstream“ option there is no guaranteed success, because it’s ultimately up to the owners of the upstream repository to accept or reject your pull request(s).

So, which is it? :wink:

For sure discard!
So now we know what i want to do, and what is its name. Thanks!

However searching for that i get only command line functions,
how to do it from level of github platform?

I don’t think you can do that using the web interface, unless you want to delete your fork and recreate it.

On the command line I think the easiest way would be to git reset your branch to the state of the upstream branch, and then force-push to your fork.

Nice :slight_smile: so i will just remove it, thanks for advice!

1 Like