what is the use of "remote tracking branch" in egit - eclipse

I am new to git and egit. First thing i did was i clone one git repo. Now when I switch to git repositoy view in eclipse, I can see Local and Remote Traking folder under branch. I am not sure what is the purpose of Remote tracking here ?

The use of remote tracking branch in EGit is the same as in the command line Git:
Under Local all local and under Remote Traking all remote branches are listed. You can only work on a local branch and in a remote branch, you can see the history (until the last fetch) from the remote repository.
A typical use case is to check out a remote branch as a new local branch. The upstream branch of the newly created local branch is then the remote branch from where you created the branch.
The fetch command is to update your remote tracking branches only.
The pull command gets, in addition, the fetched changed into your current checked-out local branch.

Related

Pushing changes made in a local branch to a remote remote if the branch doesn’t exist in remote yet

My project leader has a remote git repo named repo-A. He created a new branch named branch-a and he has been working on a feature on this branch. He gave me a small task to do and I cloned this branch-a to my local repo. I created a new branch from branch-a named branch-b and made my changes in this. Now, How do I push it back as branch-b does not exist in the remote yet?
You need to push with set upstream option activated:
git push --set-upstream origin branch_b

local git repository with two remote git repositories

On my local git repo, I used to push it to two different remote repo, one on github and another on heroku. Now my local is stuck on heroku repo and I want to create a branch from github master branch. How can I change from heroku to github(origin)?
[thi is what my terminal looks like]
See here - you want to set your local branch to track a different remote: Make an existing Git branch track a remote branch?

git fetch not working for fetch new files

I am new to Github and have checked lots of examples for fetching and pulling files from the Git server. However, my fetch command does not work as I expected; my pull command works as I expected and downloads new files onto my system. Is the fetch command not able to download files locally to my branch?
You need to understand the difference between fetching and pulling. When you do a fetch:
git fetch
you update all the local tracking branches in your Git folder. The tracking branches are your local copy of what is actually on the repository, and it is these branches which Git uses for most operations. This means that every tracking branch will now be in sync with the latest changes from GitHub. However, this does not mean that the local branch you have is now up to date. To bring your local branch up to date you have to additionally either merge or rebase that branch on the remote tracking branch.
Assuming you are on the master branch, you can remember what git pull does as follows:
git pull = git fetch + git merge origin/master
In other words, there is merge here to actually get the changes from the remote repository into your local branch. You could also rebase your local branch on the version in the remote via git pull --rebase master.
So the answer to your question is that the fetch command absolutely does bring in changes from the remote to your system, but you have to additionally merge or rebase to update your local working branch.

Commit in github repo branch

I finished coding a website in my local computer. Now need upload it to one branch github repo. like https://github.com/xxxx/test.git branch 001
Can you tell me how to commit it in the repo branch
I have already create a local repo commit all files into it by Netbeans. So How can i push the local repo to remote repo branch?
Thanks
When you locally create a branch Git automatically takes care of creating a new branch on the remote server. Just normally do
git push
It will create the branch on the remote server.

Egit push doesn't change files in remote repository

I came to know about the git / egit version control system last week, seems too good to be true .So thought to shift from SVN to git..Since last week I am trying to understand the basics and concepts of git.
So I created a test environment for understanding the workflow of egit in eclipse as following.
I am following the strategy of remote tracking there are two repositories named local and remote used for understanding the workflow.
I created a repository named 'remote' with an emtpy index.php file and has one master branch and imported the project into eclipse.
I created another git repository named 'local' by cloning the above 'remote' git repo, this repository is now tracked by 'remote' repository has one master branch and origin/master remote tracking branch.
I imported the project from 'local' git repo. into my eclipse workbench and changed the index.php file using eclipse php editor -> committed changes to local's master branch and -> performed push from local master branch.
When checking the remote working directory .. there is no change updated which I did in local's index.php file , however master branch in the remote repository view shows the latest commit which I committed in the local's master branch, but unfortunately files are not updated, it just adds asterisk mark to all changed files in my remote project view.
So researching about the asterisk mark I found its in staged condition .So can anyone lead me to the right way explaining how to successfully perform push operation from local's master branch to remote's branch I will be grateful.
this is the picture of my egit test case set up in eclipse for understanding the workflow. you can see the asterisk mark in the remote project after performing push from local repository,you can see all three branches viz.local's master, origin/master and remote's master branches shows same latest commit.
1
Thank You.
I tried using bare repo. as a remote, when I push from changes from local to remote, I don't find any files in remote repo. Just branch gets updated with the latest commit.
That seems normal, since a bare repo has *no working tree, meaning no files.
You would need to clone that remote repo, and add this cloned repo (non-bare) as a project in your Eclipse, in order to:
push from your first Egit-managed repo to the bare remote repo
pull from that same bare repo to your second Egit-managed non-bare repo.