Questions tagged [git-track]

In git, tracking branches are local branches that relate to a remote branch.

Pull/push operations in git have to specify a repository and branch to pull from (or push to). A branch can be made to track a specific branch so that push/pull operations take the tracked branch as the default target.

For example, when cloning a repository, the master branch will track the corresponding branch origin/master. and

When you check out a local branch from a remote branch, a tracking branch is created automatically:

git checkout local_branch1 remote_rep/branch1

If you want to use the same name as the tracked branched you can use

git checkout --track remote_rep/branch1

See also:

30 questions
2
votes
1 answer

Excluding certain files while 'git pull'

I am doing a complex PHP project with two other people. We had git setup for the project from the beginning. After working for two months, we wanted to remove certain folders (/dev/app) from git tracking ( git was already tracking them). So I…
Fawzan
  • 4,738
  • 8
  • 41
  • 85
1
vote
2 answers

How to change git subrepo to track a differentt branch?

I have a subrepo in an ext/[subrep] directory that I want to track a different branch. I have followed the instructions for switching subrepo branches at https://github.com/ingydotnet/git-subrepo/wiki/FAQ however, it does not seem to be…
wiyosaya
  • 95
  • 9
1
vote
2 answers

Git: how to untrack files without staging them for deletion

I have some config files that I want to change locally but not risk accidentally committing those changes. They also cannot be added to gitignore because they need to be tracked for the project as a whole. When I modify those files to suit my…
Andrew Toups
  • 189
  • 10
1
vote
1 answer

Updating local branch from the tracking remote branch without losing changes in local branch

I have cloned a remote branch A from github, and checked out a local branch feature/test from it For example - git clone A git checkout -b feature/test Now i started working on feature/test and did some changes in it and commited but not pushed.…
Derrick
  • 3,669
  • 5
  • 35
  • 50
1
vote
1 answer

Git ignore file change but only once?

Does Git have some kind of "ignore once" function? I want git to ignore a change to a file only this time, is it possible? I have a tracked file with variables , I want to change: Debug: 'true' too be 'false', I don't want the file to show up…
Sebastian Norr
  • 7,686
  • 2
  • 12
  • 17
1
vote
1 answer

Add files to .git and do not delete them when pushing to upstream

I am looking into adding some files to .git repo directory, and push them to the upstream without tracking/commiting them. Example: .git/information.txt After I do a commit, I add text to information.txt, and then push. When I clone/fork I would…
scas
  • 221
  • 2
  • 9
1
vote
3 answers

git undo mistaken tracking branch

i wanted to setup my local mainline branch to track origin/mainline but used the command git branch --set-upstream origin/mainline mainline by mistake, with the outcome Branch origin/mainline set up to track local branch mainline. How can I fix…
user949110
  • 543
  • 7
  • 20
0
votes
1 answer

git: What if a second branch tracks another branch in origin?

What are the consequences of having a remote branch with the same origin as another one? For example // Create branch foo but track origin/bar instead of origin/foo git branch --track foo origin/bar git push origin foo What are the side…
Alex Nolasco
  • 18,750
  • 9
  • 86
  • 81
0
votes
2 answers

Git: Track two branches, when files are located differently on each one

Given I'm on first branch, tracking 'foo' and 'bar' files, like this: my_repository/ ./foo ./bar How could I also track another branch (remote), where this 'foo' and 'bar' files are located under another location? I.e., when…
Gabriel L. Oliveira
  • 3,922
  • 6
  • 31
  • 40
0
votes
1 answer

How do I show only branch out-of-dateness information from `git status`?

Typically git status shows: Current branch name (or detached HEAD status) Whether upstream branch (if any) is ahead, behind or diverged Changed staged for commit Changes not staged for commit Untracked files How do I view only 1 and 2 without…
Vi.
  • 37,014
  • 18
  • 93
  • 148
0
votes
1 answer

Can Git track an ancestor branch as well as its own branch?

Sorry if this is a noob question, but I've been searching for an hour+ and can't get a clear answer. What I'd like to do is this: Checkout a remote branch git checkout origin/feature Make a local branch based off that branch git checkout -b…
Atom999
  • 432
  • 5
  • 17
0
votes
0 answers

Why would local "remotes/origin/master" be out of sync with the actual remote branch?

I am wondering, if you do this: git fetch origin master; and the above command succeeds - under what circumstances would the branch "remotes/origin/master" ever be out of sync with the actual remote branch (on Github)? From my observations, it…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

git pushes untracked files

~/D/s/b/h_adv_ML (master±) ▶︎︎ git ls-files --error-unmatch *.csv test_rmse.csv train_rmse.csv error: pathspec 'genome-scores.csv' did not match any file(s) known to git. error: pathspec 'genome-tags.csv' did not match any file(s) known to…
Abhishek Bhatia
  • 9,404
  • 26
  • 87
  • 142
0
votes
1 answer

How to compare branch against deliberately unknown upstream?

How can I compare a local branch against its remote upstream when I don't want to keep in mind what remote branch is its upstream? In other words, I want to drop origin/bar in the second line below: git branch --set-upstream master origin/bar git…
n.r.
  • 1,900
  • 15
  • 20
-2
votes
1 answer

Git: how to reset untracked files?

I made a commit, then changed some files in my project, then did git reset --hard HEAD. It said untracked files for all the files I had added. How do I resolve this so that those files are tracked and get reset along with the rest of the project?
gkeenley
  • 6,088
  • 8
  • 54
  • 129
1
2