0

I am a tester and have limited knowledge about Git. I have cloned a project to create local repository. When I have to get changes for last 'x' days,
I run git pull followed by git diff '@{ x days ago}'.

Now I want to get changes in developers branch. So I have cloned his branch in another repository using git clone -b dev_branch <url>. How can I get his diffs for last x days?

Also comment about doing the both tasks in same repository.
Thanks

Ethan Hunt
  • 93
  • 1
  • 1
  • 9

2 Answers2

0

You can clone entire repository at one place.

git clone <URL>

After Successful clone

git branch -a 

This will list all available branches

Switch to developer branch

git checkout <dev_branch_name>

Perform Your differences operation.

Rishabh Dugar
  • 606
  • 5
  • 16
  • Correct me if I am wrong, for getting changes in master, I'll need to `checkout -f master` and then do difference operation? Can I freely switch like this and get correct diffs? – Ethan Hunt Nov 07 '17 at 04:02
  • yes, you can simply do git checkout master , (not sure what -f does), to confirm your current branch you can always do git status – Rishabh Dugar Nov 07 '17 at 04:05
  • `-f is for forceful checkout`. To perform `git diff` I need to do `git pull`. how can I do that in dev_branch after `git checkout dev_branch`? will that create problem while switching branch? – Ethan Hunt Nov 07 '17 at 05:02
  • No, there is no issue , you can do git pull origin while you are in dev branch – Rishabh Dugar Nov 07 '17 at 06:00
0

Git supports many different remotes, and depending on your structure, you might be able to use this:

git remote add <remotename> <developer-url>
git checkout -b dev-branch <remotename>/dev-branch

This allows you to use git in a completely decentralised way. However, it will probably be easier to have a central main repository and have all developers push branches to there, feature branches as well as production-ready code.

If other developers want to push feature branches it would look like this:

git checkout -b feature
git push -u origin feature

If it's their version of the release branch, I'd argue that it's still a feature branch as you're not ready to put it into release yet, but you can still push to a branch on the remote with a different name, it's just perhaps not the best practice:

git checkout release
git push origin HEAD:developername-release-branch
cmbuckley
  • 40,217
  • 9
  • 77
  • 91