1

We are currently using ClearCase for managing our source code.

With ClearCase, i'm used to making several changes, and to be able to commit (check in) these changes to the server in any way that i want.

This also means i can edit (check out and modify) 10 different files, but check in only some of these back to the server, and in any order that i'd like to.

With git, commiting locally forces me to push the changes back to the server in that particular order.

Is there any workflow in Git, that is similar to the one i'm used to with ClearCase? (being able to push only some of my local commits to the server without loads of work).

lysergic-acid
  • 19,570
  • 21
  • 109
  • 218

2 Answers2

1

In addition of adding files to the index (which allows you to pull only the files you want), you can also:

  • add interactively part of a file to the index (meaning you push only part of a file if you want: you cannot do that with ClearCase)
  • stash at any point your files being modified, in order to refresh your workspace (git pull), and then re-apply those changes to your working tree.
    That is easier than in ClearCase, where currently checked out files aren't modified when a view is refreshed (update in a snapshot view for instance).
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Let's say i commit (locally) commit_a and then commit_b. How do i push ONLY commit_b to my server repository? this is a simplified scenario, but there may be 5 commits that will make it harder. – lysergic-acid Jul 24 '12 at 13:06
  • @lysergic-acid: A better question is why did you make 5 commits that you don't want to push precede 1 commit that you do? There may be another workflow that would fit you better. – Roman Jul 24 '12 at 13:49
  • 1
    @lysergic-acid publishing means having a clear, sequential history: git rebase -i will allow you to quickly reorder your n commits, with the public ones (the ones you want to push) being first, and then followed by the more recent ones don't want to publish. Then you can push only the first ones. – VonC Jul 24 '12 at 14:34
  • @lysergic-acid however, the real solution consists in creating a branch in which you know you want to push everything. – VonC Jul 24 '12 at 14:34
  • @VonC My main issue is doing the same workflow as we're used to: Make several changes. Commit these as several commits and then choose which to publish to the server. With ClearCase, the main difference is there's no "local" commit stage before sending changes to the server, so any of my local changes can be applied (or not applied) to the server (published). – lysergic-acid Jul 24 '12 at 14:57
  • 1
    @lysergic-acid but you can commit whenever you want. You only have to `rebase` (`--interactive`) before pushing though. That is the equivalent of "choose which to publish to the server". – VonC Jul 24 '12 at 18:11
  • Thanks, seems like this is the way to go. The only issue is educating the team on these extra steps and commands. That is the reason i was wondering if there were other easier ("automatic") ways to achieve this. – lysergic-acid Jul 24 '12 at 18:30
  • 1
    @lysergic-acid no other way I know of. Consider also the other differences between ClearCase and Git: http://stackoverflow.com/questions/645008/what-are-the-basic-clearcase-concepts-every-developer-should-know/645771#645771 . And between CVCS and DVCS: http://stackoverflow.com/questions/2704996/describe-your-workflow-of-using-version-control-vcs-or-dvcs – VonC Jul 24 '12 at 18:46
0

In reply to:

This also means i can edit (check out and modify) 10 different files, but check in only some of these back to the server, and in any order that i'd like to.

you could stage for commit just the files you want:

>git status
# on branch xxx
# Changes not staged for commit
#    file1
#    file2
#    file3

>git add file1 file3
>git commit -m "Commited file1 and file3"

>git status
# on branch xxx
# Changes not staged for commit
#    file2
René Kolařík
  • 1,244
  • 1
  • 10
  • 18
  • yes but now when i repeat the same for file2, i wont be able to push just the second commit without the first one..(without some extra manual work) – lysergic-acid Jul 24 '12 at 09:10