I'm coming from a perforce background, trying to understand gitHub.
In Perforce when I "checkout" something it lets other users know I am working on that file. Does checkout work the same way in Git?
It seams like you don't check out files but branches?
Thanks
checkout in Perforce would roughly equate to clone in git, but in VCS like git ( and even SVN ), the checkout doesn't signal lock to others that you are working on it. Anyone can clone a git repo and work on it without thinking about who else is working on it.
In general, checking out a branch does not mean anyone gets notified. It simply means you are switching from one branch of code to another, potentially also creating a new branch in the process depending on your arguments.
For more info about checkout, see git checkout documentation.
Related
I'm struggling with an issue connected to GitHub. I've committed some changes using GitBash console and got an info that the push was successful and there's nothing to commit. When I went into logs, there was this particular log looking like this:
The issue is that when I go back into my GitHub account, I can see just an initial commit in there, nothing more.
And the console clearly says that the commit was successful.
Please help!
Git is a distributed version control system, so you have one local copy of the repository, Github has another copy. As far as git is concerned every copy is equally important.
For your changes to exist in Github, you have to push them there, with something like:
git push origin master
Try git remote -v to get more information on your tracked repositories. Github has some great help pages on this stuff.
For what you say in your question, I think you don't have actually pulled your local repository in your GitHub account.
To do that, use git push origin master
When you use git commit your changes are saved in your local repository, not in your remote (that in this case is GitHub)
Thanks to all that helped me understand my issue. Turns out the files did not copy between folders properly and that's why there're not changes detected on git. Now everything is working.
Thanks again!
Our team is looking to migrate our perforce server over to Git. Is there a way to sync check-ins from a branch in our Github Server back to Perforce to keep them in sync? I have been looking at git-p4 and there seems to be lots of documentation of how to sync Perforce -> Git but not the other way around. I would ideally like to have it syncing both ways perforce <-> git, is that possible with p4-git?
Perforce GitFusion can do this, but the developer would have to push changes to the GitFusion server instead of the github server.
For most of the time, merge conflicts were sorted out automatically. Perforce was the "master". People submitting from Perforce always had their change go straight through. People submitting from git would have their change submitted via this process:
lock master git repo
fetch upstream p4 changes
rebase against upstream p4
submit to p4 if that all went ok
That still left a very small window between (3) and (4) where someone in Perforce land could submit a conflicting change to the same files. But in practice that only happened a couple of times, over the course of several years of probably hundreds of commits per week.
In those two cases I went in and manually patched things up which was a bit clunky. I think you could just automatically discard the problematic change quite easily, but in the end, switching to git entirely made this problem go away.
Git-p4 is designed such that the git repository is initialized with data imported from Perforce. After this initial import bidirectional communication between git and Perforce repositories is fully supported, with the exception of branches/merges that have limited support.
To import updates from Perforce to git:
git p4 sync
To submit changes from git to Perforce:
git p4 submit
For more details regarding git-p4 configuration please consult its documentation.
Update: I would always advise to test any flows in temporary repositories before deploying.
In the past I setup something like this. I had a gitolite repo and a p4 server. Changes pushed to the gitolite repo would be picked up by a cron job and turned into P4 commits (via git-p4 submit). Similarly, changes submitted to p4 would be picked up by the same cron job and synced back to git (via git p4 rebase).
There were two git repos involved: the gitolite repo that normal git developers committed to, and a separate git-p4 based repo where the git-p4 operations took place.
I had a fairly small shell script to co-ordinate everything. The main tricky areas were:
locking: you have to forcibly rebase the gitolite repo so you need some way to ensure developers don't lose changes when this happens (I used a lock file).
Merge conflicts. Very occasionally two people would edit the same section of a file in P4 and git at the same time.
I have faced this problem myself and as far as I know there's nothing of the kind.
In my case I have to basically:
Create a patch for the changes in Git: git diff sha1..sha2 > mypatch.diff
Make a list of the affected files: git diff --name-only sha1..sha2 > files.list
Apply the patch in the P4 repo: git apply mypatch.diff
Reconcile changes in P4: for each file in files.list; p4 reconcile $file; done
Edit your P4 change list and then submit it (I'm sure this can be automated too but I haven't had the need for it).
I have a couple of scripts that help me with this, you can find them here: https://github.com/pgpbpadilla/git-p4-helpers#sharing-changes-git-p4
I have been using this workflow for ~6mo and it works for most cases.
Caveats
This creates a single change lists for all commits in the sha range (a..b).
I have project A. The project A is in perforce as well as in github( Business decision). They are both out of sync. I see that I can use git-p4 tool http://git-scm.com/docs/git-p4 to submit git changes to perforce. Problem is first instruction of it says is:
git p4 clone //depot/path/project
This command will create a new repo in git hub. I do not want that. I want my existing perforce depot to connect to exiting github repo and then sync files from github to perforce. Is it possible?
No. git p4 is basically just a wrapper around Perforce. It reads changes to a Git repo and issues the proper Perforce commands to commit them (and vice-versa -- it reads changes to a Perforce checkout and issues the proper Git commands to update a Git repo accordingly). So you need to have a Perforce checkout and a local Git repo that can talk to that Perforce checkout.
Fundamentally you have two different histories for the same project, so you need to find some way to reconcile them.
git-p4 can sync from Perforce (create a new git repository), then you can add a new remote pointing to github, and sync the branches from there.
However that doesn't help with the problem of merging the histories.
You can either:
Go with Perforce, and rewrite github history
Go with Github history, and get your perforce admin/Perforce (company) to rewrite your Perforce history.
2 is probably (politically) impossible. May be impossible technically. Perforce is designed to prevent history from being altered.
1 will break anyone cloned from your github repository.
You may want to take a look at Git Fusion, which is a bridge between Git and Perforce:
http://www.perforce.com/git-fusion
This KB article gives an example of how you may wish to work with a project that is both in Perforce and a public Git repo:
http://answers.perforce.com/articles/KB/7481/
Hope this helps!
Coming from a SVN world, wrapping my head around Git has been a little weird, and I'm having trouble letting go of some of the practices ingrained in me from using Subversion for so long. So, for example, in SVN a branching structure might look like this:
-Trunk
--Master
-Branches
--SomeFeatureBranchA
--SomeFeatureBranchB
So, in this situation my Master branch has it's own set of code, and once I check out SomeFeatureBranchA & SomeFeatureBranchB, they'll have their own code. However, when I create a branch in Git, I see my branch listed, but at this point I'm unsure of how to edit the code for that branch.
Do I clone that branch down & simply rename it like:
-Trunk
--Master
--SomeFeatureBranchA
Or is there some command I'm missing that handles this for me?
Thanks for taking your time to help me out!
git branch will tell you which branch you're currently on (as will git status). Just edit as you normally do, if you're on the right branch. If you're on the wrong branch git checkout some branch will get you there. The top of the git repository is the equivalent of subversion /trunk or /branches/SomeFeatureBranchA.
Forget everything you know about SVN when working with Git. You described your problem by comparing it with SVN, which makes it pretty difficult to understand what your problem actually is.
You created a branch in git (either with git branch <name> or git checkout -b <name>) and made it your active branch. Simply start hacking away at the code to edit your branch. When you're done, stage (read "add") and commit your changes, then push them at a later time if you're working with a remote tracking repository.
Does that answer your question? If not, can you please clarify what exactly it is you're trying to do?
I am trying to find the right way to do this. My firm is using SVN as we are working on the projects to do checkin and checkouts. But I am thinking about using Git to backup all my work as I got home.. here is why
From Home I don't have access to my firms SVN Repo so I was thinking about setting up a Git Repo on the internet to checkin all my work into git before I leave work so I can access it from home.
I would like to hear if others are doing this and if you think this is a good practice.
How would I do this? I been using SVN and Eclipse for sometime now but I hear GIT would be better for cloning my workstation...
The solution to this for many people is 'git svn'. It allows you to create a local git repo as a clone of a tree in svn, work locally, and commit your work back to svn.
You can run git svn while at work, copy the resulting repo to a disk you carry home, and then commit back to svn when you get back to work. Always assuming, of course, that your employer's policies permit this. If you can't get to svn from home, perhaps they don't like anything about this idea.