Numbers on the push and pull button of SourceTree won't change - github

I started using SourceTree few days ago and after I committed and pushed my changes to the remote GitHub repository, the numbers on the buttons remain the same, for example if the number on the push button becomes 3 when I committed a change, after I pushed it; it needs to be 0 or empty. But that's not the case here, it remains the same even though it has successfully been pushed. I also checked that my changes had been pushed using a web browser by going to the GitHub site. Is it because of the branch that I have pulled from and am pushing to are different or something else? Can any one please help cause I don't understand it... Thanks!

The numbers shown on the right hand side of the Branches panel reflect how many commits ahead or behind the Tracking Branch you currently are. If the numbers aren't what you expect, you should verify that the branch is tracking what you actually want.
You can verify the tracking branch by right clicking your local branch (as depicted below) and expanding the Track remote branch menu item. Finally, if you want to change the tracking branch simply click the new target from the list and Sourcetree will update accordingly. Hopefully that helps make sense of the disconnect that can happen when you rename branches and provides some details around why it happens and a simple way to resolve.

The same thing also happened to me too, I was working on branch I had push everting but was keeping appearing one unsend Push and miraculously also appear unsend Push on Master.
So what did was the same as Hristo Staykov and Sammie remove the Master branch from my local computer, since I had one miraculously unsend Push on Master did need to run this line terminal to remove the branch:
git branch -D master
And then Repository > Refresh Remote Status

I simply use the keyboard shortcut from the Repository menu:
CTRL+ALT+R (or control+option+R if you prefer)
My guess is that the shortcut would be the same or at least similar on Windows. Just look for the option called Refresh Remote Status under the Repository menu.

Related

Regarding GitHub and version control

Recently, we have started a group project and decided to use GitHub to share the code among ourselves.
For example, if I created a login page and my friend created a home page, how can I get it on my local machine.
I mean, whenever a change is made to the repo, do we need to download it all again?
The beauty of GitHub is that you can always go back whenever you feel like.
Whenever a changed is made by any of the teammate, it's a really good practice that you push that change. Even when it's a small one. After you've pushed your changes, your teammates would need to pull that change.
The best sequence for this is;
- git commit
- git pull
- git push
You'll have to pull the changes first as it would help you avoid getting merge conflicts. If you get any merge conflicts on any line, or any function, you'll resolve that conflict and follow the same sequence once again.
So, to conclude, GitHub is so easy to use and you won't have to necessary 'Download' all the changes once again. I would recommend you to setup via Visual Studio 2019 so that it becomes easier for you to just "pull" the changes whenever a new change has been made.

How do you push in Github Desktop

Github Desktop version is Chocolate-Covered Yaks (3.3.4.0) 50415df.
There are a lot of tutorials and responses on here, but all of them talk about things like sync buttons. There is no sync in this version.
The files have been committed. Clicking on 'open this repository in explorer' shows all the correct files on the local computer, but they do not show up on the website.
Does anyone know how to push in the new version?
Alright. I'm assuming you have cloned the repo you are working in. And you own the repo you are working in. Meaning you have full access to the repo and you can push and commit to the repo.
https://i.imgur.com/K8zwLem.png
You need to make changes to your local files, it would show up like so in the screenshot above.
Once you have changes you are satisfied with, write something in the summary box and "commit" to the branch you are working on.
After you commit, you should get a button on the top right saying "Push origin"
https://i.imgur.com/K8zwLem.png
If you don't see it, try pressing the pull button before you push.

Source tree not able to push

So I make my file changes, but when I try to push them source tree complains that some one else pushed before me.The files are different,yet I am forced to merge the changes. Some times I have to backup and reset my workspace before it can allow me to push again
Is there no way to force the push?
Open SourceTree Preferences
Tab: Advanced
Third checkbox: Allow force push
Enable the checkbox and close Preferences.
Next time you push, there will be an extra checkbox: Force push.
Checking it will also display an additional Confirm Force Push dialog box before the force push is actually performed.
Even though the files are different, you have to perform a merge or a rebase before you can push. The commits from your current working branch have to be merged into the current branch that exists on the server before you can update it. You're merging the branches, not the files.
Using the "force push" command does not force your commits to be applied in addition to what is on the remote branch - it forces your commits to replace the commits on the remote branch. Using this option would throw away all of the commits that had been made by the other user.
Because this is a destructive operation, SourceTree does not include GUI access to the "force push" command. Here's what Steve Streeting from Atlassian says about it:
SourceTree doesn't expose force push because it's almost always not what you want to do.
It means that someone else has pushed before you. What you should be doing is pulling their changes, merging them (or rebasing your changes on top of them), and then pushing.

Github for mac - pushing selected files only

I'm new to github and currently only starting off using github for mac.
I have taken a clone of my client's website and made some development changes locally. Note: I'm literally working with the files in the directory I sync with.
I want to push only one small change as the rest is still under development. Is it possible to push only the one file?
Git pushes deal with commits, not files. You'll need to create a commit that contains your selected changes. This is one area where Git's index is really handy.
Let's say you've modified two files, foo and bar.
If you want to commit only the changes to foo, using the command line you can do
git add foo
git commit
This will create a new commit updating foo, but bar's changes will remain only in your working copy. You can now push the new commit.
It's been a while since I've used the graphical GitHub tools, and I've only used them on Windows, but I believe the way to commit only certain files is to check or uncheck the box beside each file before you commit. You can see these checkboxes in their documentation:
You can go even further. If some of the changes in bar should be part of a commit, but not all of them, you can do something like git add --patch, which will break your changes up into chunks and prompt you for the ones to add to the index (these are the ones that will be included when you commit).
On GitHub for Mac you can do this too:
Select one or more lines to commit by clicking on the line numbers in the gutter. In the latest release, you can select a block of changes at a time. Hover over the right hand side of the line numbers to get a preview of what will be selected, and click to select.
See the documentation for git-add for details.

Branched locally, pushed to master, need a code review on GitHub

I may have screwed up, but there a way to get a code review going on GitHub after I did the below workflow?
I cloned a remote repository, branched the master and made my changes. I committed the changes, merged my branch into master, then ran a sync on GitHub and the changes are there now.
I'd now like to initiate a post-checkin review, but didn't fork the repository and so can't initiate a pull request, which as I understand it now is the common way to get reviews going in github. What should my next steps be?
Next time you should just push your changes from your branch to the remote repository, then submit a "pull request" for the branch back into master where the code can be reviewed prior to merging.
When you push changes to your branch, to compare your changes, go to that branch and look for this near the top in the code tab:
This is some good reading as well about how/when to use forking & pull requests: https://help.github.com/articles/using-pull-requests
EDIT:
And since you did say this is after the fact, the other thing you can do is go to the master branch->commits section, and click on the commit where you merged your branch in. That page allows you to make comments and view the changed files, so you can still review your code before you actually push it to your server. However, you should still do the other way next time.
To clarify...you can branch locally and then change, commit etc, and then push that branch to GitHub, then fire off a pull request?
Yes, and since August 14th 2018, you don't even need to switch to the Code tab:
When you push branches while using the “Pull requests” tab, GitHub will now display the dynamic “Compare and pull request” widget—so you can quickly create a pull request without having to switch back to the “Code” tab.
Learn more about pull requests in our documentation.