Gitbash/bitbucket: how to push changes from previous push, overwriting a "bad" push - bitbucket

I have a project I have been working on, and I was suggested to use Gitbash and Bitbucket to keep track of all the changes I will make.
I made some changes, pushed them to my bitbucket, and then cloned it to really make sure I was working on the latest files. Made a few more changes on that cloned download, tried to run it on my hardware and it wouldn't run. Couldn't figure out why either.
I went back to the previous download and managed to get it running on my hardware setup. I have made a multitude of changes since but just completely forgot to push.
Now, when I try to push, because there are files I don't have locally, I get the error:
On branch master
Your branch and 'origin/master' have diverged, and you have 2 and 5 different commits respectively.
It also tells me to git pull to merge the remote to my local files.
I do not want to do that, as that would overwrite changes I want to keep locally. I just want to push what I have locally, to my remote.
I am not a software engineer at all. All of the helps pages and tutorials are going way over my head.

Related

How to overwrite my all local changes in XCode repo when I see "Rebase local changes onto upstream changes" message?

I have a Bitbucket repo where the most recent changes are pushed by another developer teammate. His push is more important and I want to make sure my local is same as the latest in the repo. I have not made any changes but still Xcode shows me this warning. I am fine is all my local is overwritten. How do I do it? Should I check the box when I am pulling changes in Xcode from the BitBucket repo? Or do I need to do a git pull from terminal?
If you want to merge another branch into yours, you should always commit your changes first. When conflicts emerge, you just solve them and there you go, you are on the latest commit with your changes preserved.
If, however, you prefer rebase instead of merge - you HAVE to commit your uncommited changes first, then you can rebase on the latest commit from the other developer's branch, the nice thing about rebase is that it keeps the git history cleaner while also leading you trough the conflict solving, because it basically tries to put each commit of yours on top of the commit that you are rebasing onto, so it sort of "guides" you trough resolving conflicts as you have small chunks of code to resolve and then continue rebase.
Try to read more on this. This article summarises the difference between merge and rebase:
https://www.freecodecamp.org/news/an-introduction-to-git-merge-and-rebase-what-they-are-and-how-to-use-them-131b863785f/

What Discard all changes in Xcode source control actually does?

As in question, I wonder if there is some documentation about what this Xcode command does (Source Control -> Discard all changes) ?
I guess it reverts to last commit but on local branch ? Can somebody confirm that it doesn't affect the same remote branch automatically ?
I didn't use git in XCode, but I can be so sure that Discard all changes will NOT affect history in the remote.
It will most probably discard all unstaged changes you made to the tracked files in the working directory, simply like executing git checkout -- . from the terminal.
With unstaged, it means changes you once executed git add -u for will not be discarded.
By the way, to find out what it actually does, a test by yourself is needed.
I ran into a similar problem in which I wanted to roll back to my most recent local commit, and being unfamiliar with command line git, I took a chance with selecting 'Discard Changes in /filename/' and it did exactly the same thing all the websites said git checkout would do.
Once again, this is just my "test" but the feature works as advertised.

Errors on Push on Git followed by errors on Pull and Workspace

I'm really new on git, and things are really complicated. I really need all of your help!
I don't know where is the mistake so I will tell my all story from the beginning. I was working on another computer, and were able to push without an issue. Then I changed to my current computer, so download from the web (which is visual studio btw) my project, directly with the download button. Then I start working on my new project. Yesterday, I tried pushed and it told me "Everything is up-to-date". Thought, didn't accept my push. I just nevermind yesterday and continue working. Today, I tried pushing again but I figured out I didn't commit yet. So from XCode, from to top bar I go for commit and then opened the terminal again. Tried to push one more time, but here my problem is started. Because of I was working cocoapods, I was working from .xcworkspace. With the push, I am now not able to open my project. It started giving me error "Workspace Integrity(Couldn't load project). Tried re-opening several times, but ofc, didn't work. So, I still assume that is because of the push and if I handle the push problem that will also fixed. To be able to push, I found that I need to pull then push. So I tried to pull, but that also gave me the error of being unmerged files. Then, I decided to figure out a way to merge, but those I found on the net, especially on stack, there are nothing worked for me.
Things are complicated for me then you thought, because I really don't know what is git at all and it just came up with all of these error. There are lots of errors and I'm really confused.
I really need someone to help me deeply, at least telling me a way to out.
Hope that long story don't scare you, as I am scared too.
Thanks from now,
Waiting for your guidance, desperately!
You should try issuing a git fetch, and then a git merge from the terminal. This is usually a better way than to use git pull. git status is your best friend too, it will show any files that have not been added to your staging area. If you have files that have not been added yet, you can either run a git add <filenames> or you can commit and add at the same time with
git commit -a -m "commit message"
Hope this helps at least a little.
Also, you definitely don't want to corrupt your remote repo, so don't push your local repo if it's bad. If your remote repo is still okay, you can clone it again, and add the changes that you made yesterday and today manually, not ideal, but it might be your only choice if you can't open your files.

Github development, deployment process for ios apps

we have a team of 3 and have about 10 clients for our branded/customized apps
All of the customized apps have a central code base in git (master).
We would like to use git as the central repository for all of the apps.
What we would like to achieve is:
we will set up a code base as master, it has its dummy graphics and data.
Each time we have a new client, we will make a new branch (client1). Update graphics and customize the app, then we deploy to the production.
So developers will work on their local machines, make a sub branch (client1-1, client1-2) etc
then commit back to parent branch (client1).
Later, if we want to commit a change from client 1-1 all the way back to master, is that possible?
Also, is that the standard development process for iOS app ?
I feel that is not a good idea because, when you deploy to production or merge with the master, you will be practically be spending a lot of time on merge conflicts, then getting the code to the production. If i were you, I will have 10 different git repositories and if a new customer comes, then i will create a new one. Since, git is free, creating a repository will not be difficult. Saves you a lot of time and tension as well. Once the repository is ready, then clear all your production to make it as if new. Then push the ready repository. Hope this helps...

How can I move my changes to a new branch after the fact?

I was working on my Rails project which is checked into Git. I read tutorials and they said for every time you start to change something, check out a branch.
However, accidentally I made some changes but did not check out a branch.
What should I do now?
What commands can I run so that Git takes my new changes and push them on my repository?
git stash
git checkout $correct_branch
git stash apply
Of course, if your changes are already on the branch you're going to put them on, just commit and go with it.
I hope you added a commit into jkp's answer. I can see somebody running that exact sequence without doing a commit and thus wiping out all their uncommitted changes...
It's not mandatory to make a branch, just best practice. It's perfectly legimate to work against master if you want. If you didn't create an explicit branch then you'll be working against master anyway and can push to that.

Resources